Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Use print() function in both Python 2 and Python 3 #641

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
language: python
matrix:
allow_failures:
- python: 3.7
include:
- python: 2.7
- python: 3.7
dist: xenial # required for Python >= 3.7 (travis-ci/travis-ci#9069)
script: make all
3 changes: 2 additions & 1 deletion src/scripts/get-binary-url.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from __future__ import print_function
import argparse
import contextlib
from datetime import datetime
Expand Down Expand Up @@ -271,4 +272,4 @@ def mirror(source_artifact_url, uri):


if __name__ == '__main__':
print main(**vars(parser.parse_args()))
print(main(**vars(parser.parse_args())))
3 changes: 2 additions & 1 deletion src/scripts/get-wpt-revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from __future__ import print_function
import argparse
import contextlib
import httplib
Expand Down Expand Up @@ -110,4 +111,4 @@ def main(interval, retry_interval, retry_timeout):
choices=('hourly', 'two_hourly', 'six_hourly',
'twelve_hourly', 'daily', 'weekly'))

print main(**vars(parser.parse_args()))
print(main(**vars(parser.parse_args())))
3 changes: 2 additions & 1 deletion src/scripts/read-browser-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from __future__ import print_function
import argparse
import os
import re
Expand Down Expand Up @@ -121,4 +122,4 @@ def safari(binary):
'safari': safari
}.get(args.browser_name)

print read(args.binary)
print(read(args.binary))
12 changes: 6 additions & 6 deletions test/extend_hosts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def extend(self, filename, content):
def test_non_existent_file(self):
returncode, stdout, stderr = self.extend('/foo/bar/baz', 'anything')

self.assertNotEquals(returncode, 0, stdout)
self.assertNotEqual(returncode, 0, stdout)

def test_empty_file(self):
returncode, stdout, stderr = self.extend(self.temp_file, 'foobar')

self.assertEquals(returncode, 0, stderr)
self.assertEqual(returncode, 0, stderr)

self.assertTrue(hasLine(self.temp_file, 'foobar'))

Expand All @@ -56,7 +56,7 @@ def test_no_previous(self):

returncode, stdout, stderr = self.extend(self.temp_file, 'foobar')

self.assertEquals(returncode, 0, stderr)
self.assertEqual(returncode, 0, stderr)

self.assertTrue(hasLine(self.temp_file, 'first'))
self.assertTrue(hasLine(self.temp_file, 'second'))
Expand All @@ -80,7 +80,7 @@ def test_some_previous(self):

returncode, stdout, stderr = self.extend(self.temp_file, 'bar')

self.assertEquals(returncode, 0, stderr)
self.assertEqual(returncode, 0, stderr)

self.assertTrue(hasLine(self.temp_file, 'first'))
self.assertTrue(hasLine(self.temp_file, 'second'))
Expand All @@ -96,7 +96,7 @@ def test_all_previous(self):

returncode, stdout, stderr = self.extend(self.temp_file, 'bar')

self.assertEquals(returncode, 0, stderr)
self.assertEqual(returncode, 0, stderr)

self.assertTrue(hasLine(self.temp_file, 'bar'))
self.assertFalse(hasLine(self.temp_file, 'foo'))
Expand All @@ -117,7 +117,7 @@ def test_many_lines(self):
returncode, stdout, stderr = self.extend(self.temp_file,
'oof\nrab\nzab')

self.assertEquals(returncode, 0, stderr)
self.assertEqual(returncode, 0, stderr)

self.assertTrue(hasLine(self.temp_file, 'first'))
self.assertTrue(hasLine(self.temp_file, 'second'))
Expand Down
28 changes: 14 additions & 14 deletions test/run_and_verify_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,84 +60,84 @@ def run_and_verify(self, fixture_name, max_attempts):
}

def assert_success(self, result):
self.assertEquals(result['returncode'], 0, result['stderr'])
self.assertEqual(result['returncode'], 0, result['stderr'])

with open(result['log_wptreport']) as handle:
json.load(handle)

def assert_failure(self, result):
self.assertNotEquals(result['returncode'], 0, result['stdout'])
self.assertNotEqual(result['returncode'], 0, result['stdout'])

self.assertFalse(os.path.isfile(result['log_wptreport']))

def test_perfect(self):
result = self.run_and_verify('complete', 1)

self.assert_success(result)
self.assertEquals(result['attempt_count'], 1)
self.assertEqual(result['attempt_count'], 1)

def test_perfect_unused_retry(self):
result = self.run_and_verify('complete', 3)

self.assert_success(result)
self.assertEquals(result['attempt_count'], 1)
self.assertEqual(result['attempt_count'], 1)

def test_missing_fail(self):
result = self.run_and_verify('missing-complete', 1)

self.assert_failure(result)
self.assertEquals(result['attempt_count'], 1)
self.assertEqual(result['attempt_count'], 1)

def test_missing_recover(self):
result = self.run_and_verify('missing-complete', 2)

self.assert_success(result)
self.assertEquals(result['attempt_count'], 2)
self.assertEqual(result['attempt_count'], 2)

def test_extra_fail(self):
result = self.run_and_verify('extra-complete', 1)

self.assert_failure(result)
self.assertEquals(result['attempt_count'], 1)
self.assertEqual(result['attempt_count'], 1)

def test_extra_recover(self):
result = self.run_and_verify('extra-complete', 2)

self.assert_success(result)
self.assertEquals(result['attempt_count'], 2)
self.assertEqual(result['attempt_count'], 2)

def test_missingandextra_fail(self):
result = self.run_and_verify('missingandextra-complete', 1)

self.assert_failure(result)
self.assertEquals(result['attempt_count'], 1)
self.assertEqual(result['attempt_count'], 1)

def test_missingandextra_recover(self):
result = self.run_and_verify('missingandextra-complete', 2)

self.assert_success(result)
self.assertEquals(result['attempt_count'], 2)
self.assertEqual(result['attempt_count'], 2)

def test_extra_missing_fail(self):
result = self.run_and_verify('extra-missing-complete', 2)

self.assert_failure(result)
self.assertEquals(result['attempt_count'], 2)
self.assertEqual(result['attempt_count'], 2)

def test_extra_missing_recover(self):
result = self.run_and_verify('extra-missing-complete', 3)

self.assert_success(result)
self.assertEquals(result['attempt_count'], 3)
self.assertEqual(result['attempt_count'], 3)

def test_no_expectation_fail(self):
result = self.run_and_verify('noexpect-complete', 1)

self.assert_failure(result)
self.assertEquals(result['attempt_count'], 1)
self.assertEqual(result['attempt_count'], 1)

def test_no_expectation_recover(self):
result = self.run_and_verify('noexpect-complete', 2)

self.assert_success(result)
self.assertEquals(result['attempt_count'], 2)
self.assertEqual(result['attempt_count'], 2)