File tree Expand file tree Collapse file tree 5 files changed +24
-20
lines changed Expand file tree Collapse file tree 5 files changed +24
-20
lines changed Original file line number Diff line number Diff line change 4
4
5
5
from modernize .main import main
6
6
7
- sys .exit (main ())
7
+ if __name__ == "__main__" :
8
+ sys .exit (main ())
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ addopts = [
38
38
" --strict-config" ,
39
39
" --strict-markers" ,
40
40
" --cov" ,
41
- " --cov-fail-under=91.53 " ,
41
+ " --cov-fail-under=92.11 " ,
42
42
" --cov-report=term-missing:skip-covered" ,
43
43
]
44
44
xfail_strict = true
Original file line number Diff line number Diff line change 8
8
9
9
from utils import check_on_input
10
10
11
- from modernize .main import main as modernize_main
11
+ from modernize .__main__ import main as modernize_main
12
12
13
13
SINGLE_PRINT_CONTENT = """
14
14
print 'world'
Original file line number Diff line number Diff line change 1
1
from __future__ import generator_stop
2
2
3
- import sys
4
-
5
- try :
6
- from StringIO import StringIO # Python 2
7
- except ImportError :
8
- from io import StringIO # Python 3
3
+ import contextlib
4
+ import io
9
5
10
6
from utils import check_on_input
11
7
12
- from modernize .main import main as modernize_main
8
+ from modernize .__main__ import main as modernize_main
13
9
14
10
15
11
def test_list_fixers ():
16
- sio = StringIO ()
17
- real_stdout = sys .stdout
18
- sys .stdout = sio
19
- try :
20
- exitcode = modernize_main (["-l" ])
21
- finally :
22
- sys .stdout = real_stdout
23
- assert exitcode == 0 , exitcode
24
- assert "xrange_six" in sio .getvalue ()
12
+ stdout = io .StringIO ()
13
+ with contextlib .redirect_stdout (stdout ):
14
+ returncode = modernize_main (["-l" ])
15
+ assert returncode == 0
16
+ assert "xrange_six" in stdout .getvalue ()
17
+
18
+
19
+ def test_nofix_fixers (tmp_path ):
20
+ stdout = io .StringIO ()
21
+ stderr = io .StringIO ()
22
+ with contextlib .redirect_stdout (stdout ), contextlib .redirect_stderr (stderr ):
23
+ returncode = modernize_main (["--nofix=ham" , str (tmp_path )])
24
+
25
+ assert returncode == 2
26
+ assert stderr .getvalue () == "Error: fix 'ham' was not found\n "
27
+ assert stdout .getvalue () == ""
25
28
26
29
27
30
NO_SIX_SAMPLE = """\
Original file line number Diff line number Diff line change 4
4
import shutil
5
5
import tempfile
6
6
7
- from modernize .main import main as modernize_main
7
+ from modernize .__main__ import main as modernize_main
8
8
9
9
10
10
def check_on_input (
You can’t perform that action at this time.
0 commit comments