1+ import sys
12from pathlib import Path
2-
33from subprocess import check_output
44
55REPO_DIR = "repository"
@@ -29,7 +29,7 @@ class TestPotodoCLI:
2929 excluded_2 = str (config ["exclude" ][1 ])
3030
3131 def test_potodo_no_args (self ):
32- output = check_output (" potodo" ).decode ("utf-8" )
32+ output = check_output ([ sys . executable , "-m" , " potodo"] ).decode ("utf-8" )
3333 assert "# excluded 1 / 2 (50.00% translated)" in output
3434 assert "# folder 1 / 3 (33.33% translated)" in output
3535 assert (
@@ -46,10 +46,17 @@ def test_potodo_no_args(self):
4646
4747 def test_potodo_exclude (self ):
4848 output = check_output (
49- ["potodo" , "--exclude" , self .excluded_1 , self .excluded_2 ]
49+ [
50+ sys .executable ,
51+ "-m" ,
52+ "potodo" ,
53+ "--exclude" ,
54+ self .excluded_1 ,
55+ self .excluded_2 ,
56+ ]
5057 ).decode ("utf-8" )
5158 output_short = check_output (
52- ["potodo" , "-e" , self .excluded_1 , self .excluded_2 ]
59+ [sys . executable , "-m" , "potodo" , "-e" , self .excluded_1 , self .excluded_2 ]
5360 ).decode ("utf-8" )
5461 assert output == output_short
5562 assert "# excluded 1 / 2 (50.00% translated)" in output
@@ -64,8 +71,12 @@ def test_potodo_exclude(self):
6471 )
6572
6673 def test_potodo_above (self ):
67- output = check_output (["potodo" , "--above" , "40" ]).decode ("utf-8" )
68- output_short = check_output (["potodo" , "-a" , "40" ]).decode ("utf-8" )
74+ output = check_output ([sys .executable , "-m" , "potodo" , "--above" , "40" ]).decode (
75+ "utf-8"
76+ )
77+ output_short = check_output (
78+ [sys .executable , "-m" , "potodo" , "-a" , "40" ]
79+ ).decode ("utf-8" )
6980 assert output == output_short
7081 assert (
7182 "- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy"
@@ -76,8 +87,12 @@ def test_potodo_above(self):
7687 )
7788
7889 def test_potodo_below (self ):
79- output = check_output (["potodo" , "--below" , "40" ]).decode ("utf-8" )
80- output_short = check_output (["potodo" , "-b" , "40" ]).decode ("utf-8" )
90+ output = check_output ([sys .executable , "-m" , "potodo" , "--below" , "40" ]).decode (
91+ "utf-8"
92+ )
93+ output_short = check_output (
94+ [sys .executable , "-m" , "potodo" , "-b" , "40" ]
95+ ).decode ("utf-8" )
8196 assert output == output_short
8297 assert (
8398 "- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy"
@@ -89,8 +104,12 @@ def test_potodo_below(self):
89104 )
90105
91106 def test_potodo_onlyfuzzy (self ):
92- output = check_output (["potodo" , "--only-fuzzy" ]).decode ("utf-8" )
93- output_short = check_output (["potodo" , "-f" ]).decode ("utf-8" )
107+ output = check_output ([sys .executable , "-m" , "potodo" , "--only-fuzzy" ]).decode (
108+ "utf-8"
109+ )
110+ output_short = check_output ([sys .executable , "-m" , "potodo" , "-f" ]).decode (
111+ "utf-8"
112+ )
94113 assert output == output_short
95114 assert (
96115 "- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy"
@@ -102,8 +121,12 @@ def test_potodo_onlyfuzzy(self):
102121 )
103122
104123 def test_potodo_counts (self ):
105- output = check_output (["potodo" , "--counts" ]).decode ("utf-8" )
106- output_short = check_output (["potodo" , "-c" ]).decode ("utf-8" )
124+ output = check_output ([sys .executable , "-m" , "potodo" , "--counts" ]).decode (
125+ "utf-8"
126+ )
127+ output_short = check_output ([sys .executable , "-m" , "potodo" , "-c" ]).decode (
128+ "utf-8"
129+ )
107130 assert output == output_short
108131 assert (
109132 "- excluded.po 1 / 2 ( 50.0% translated)"
@@ -116,7 +139,9 @@ def test_potodo_counts(self):
116139 )
117140
118141 def test_potodo_exclude_fuzzy (self ):
119- output = check_output (["potodo" , "--exclude-fuzzy" ]).decode ("utf-8" )
142+ output = check_output (
143+ [sys .executable , "-m" , "potodo" , "--exclude-fuzzy" ]
144+ ).decode ("utf-8" )
120145 assert (
121146 "- excluded.po 1 / 2 ( 50.0% translated)" in output
122147 )
@@ -126,8 +151,12 @@ def test_potodo_exclude_fuzzy(self):
126151 )
127152
128153 def test_potodo_matching_files_solo (self ):
129- output = check_output (["potodo" , "--matching-files" ]).decode ("utf-8" )
130- output_short = check_output (["potodo" , "-l" ]).decode ("utf-8" )
154+ output = check_output (
155+ [sys .executable , "-m" , "potodo" , "--matching-files" ]
156+ ).decode ("utf-8" )
157+ output_short = check_output ([sys .executable , "-m" , "potodo" , "-l" ]).decode (
158+ "utf-8"
159+ )
131160 assert output == output_short
132161 assert "excluded/file4.po" in output
133162 assert "folder/excluded.po" in output
@@ -136,10 +165,12 @@ def test_potodo_matching_files_solo(self):
136165 assert "file2.po" in output
137166
138167 def test_potodo_matching_files_fuzzy (self ):
139- output = check_output (["potodo" , "--matching-files" , "--only-fuzzy" ]).decode (
140- "utf-8"
141- )
142- output_short = check_output (["potodo" , "-l" , "-f" ]).decode ("utf-8" )
168+ output = check_output (
169+ [sys .executable , "-m" , "potodo" , "--matching-files" , "--only-fuzzy" ]
170+ ).decode ("utf-8" )
171+ output_short = check_output (
172+ [sys .executable , "-m" , "potodo" , "-l" , "-f" ]
173+ ).decode ("utf-8" )
143174 assert output == output_short
144175 assert "file1.po" in output
145176
0 commit comments