Skip to content

Commit 81a0f18

Browse files
committed
Add failing tests for the cause of issue #119
It seems that sys.exit(newint) (and other longs) always returns 1!
1 parent 91b800d commit 81a0f18

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/test_future/test_futurize.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717

1818

1919
class TestLibFuturize(unittest.TestCase):
20+
def test_correct_exit_status(self):
21+
"""
22+
Issue #119: futurize and pasteurize were not exiting with the correct
23+
status code. This is because the status code returned from
24+
libfuturize.main.main() etc. was a ``newint``, which sys.exit() always
25+
translates into 1!
26+
"""
27+
from libfuturize.main import main
28+
# Try futurizing this test script:
29+
retcode = main([__file__])
30+
self.assertTrue(isinstance(retcode, int)) # i.e. Py2 builtin int
31+
2032
def test_is_shebang_comment(self):
2133
"""
2234
Tests whether the fixer_util.is_encoding_comment() function is working.

tests/test_future/test_pasteurize.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ def test_urllib_refactor2(self):
129129
filename = urllib_parse.urlparse(url)[2].split('/')[-1]
130130
"""
131131

132+
def test_correct_exit_status(self):
133+
"""
134+
Issue #119: futurize and pasteurize were not exiting with the correct
135+
status code. This is because the status code returned from
136+
libfuturize.main.main() etc. was a ``newint``, which sys.exit() always
137+
translates into 1!
138+
"""
139+
from libpasteurize.main import main
140+
# Try pasteurizing this test script:
141+
retcode = main([__file__])
142+
self.assertTrue(isinstance(retcode, int)) # i.e. Py2 builtin int
143+
132144

133145
class TestFuturizeAnnotations(CodeHandler):
134146
@unittest.expectedFailure

0 commit comments

Comments
 (0)