11import os
2+ import re
23import sys
34from textwrap import dedent
45
@@ -2085,18 +2086,16 @@ def test_parse_recreate(self, newconfig):
20852086
20862087class TestCmdInvocation :
20872088 def test_help (self , cmd ):
2088- result = cmd . run ( "tox" , "-h" )
2089+ result = cmd ( "-h" )
20892090 assert not result .ret
2090- result .stdout .fnmatch_lines ([
2091- "*help*"
2092- ])
2091+ assert not result .err
2092+ assert re .match (r'usage:.*help.*' , result .out , re .DOTALL )
20932093
20942094 def test_version_simple (self , cmd ):
2095- result = cmd . run ( "tox" , "--version" )
2095+ result = cmd ( "--version" )
20962096 assert not result .ret
2097- stdout = result .stdout .str ()
2098- assert tox .__version__ in stdout
2099- assert "imported from" in stdout
2097+ from tox import __version__
2098+ assert "{} imported from" .format (__version__ ) in result .out
21002099
21012100 def test_version_no_plugins (self ):
21022101 pm = PluginManager ('fakeprject' )
@@ -2163,14 +2162,8 @@ def test_listenvs(self, cmd, initproj):
21632162 changedir = docs
21642163 '''
21652164 })
2166- result = cmd .run ("tox" , "-l" )
2167- result .stdout .fnmatch_lines ("""
2168- py36
2169- py27
2170- py34
2171- pypy
2172- docs
2173- """ )
2165+ result = cmd ("-l" )
2166+ assert result .outlines == ['py36' , 'py27' , 'py34' , 'pypy' , 'docs' ]
21742167
21752168 def test_listenvs_verbose_description (self , cmd , initproj ):
21762169 initproj ('listenvs_verbose_description' , filedefs = {
@@ -2193,15 +2186,14 @@ def test_listenvs_verbose_description(self, cmd, initproj):
21932186 description = let me overwrite that
21942187 '''
21952188 })
2196- result = cmd .run ("tox" , "-lv" )
2197- result .stdout .fnmatch_lines ("""
2198- default environments:
2199- py36 -> run pytest on Python 3.6
2200- py27 -> run pytest on Python 2.7
2201- py34 -> run pytest on Python 3.4
2202- pypy -> publish to pypy
2203- docs -> let me overwrite that
2204- """ )
2189+ result = cmd ("-lv" )
2190+ assert result .outlines [2 :] == [
2191+ 'default environments:' ,
2192+ 'py36 -> run pytest on Python 3.6' ,
2193+ 'py27 -> run pytest on Python 2.7' ,
2194+ 'py34 -> run pytest on Python 3.4' ,
2195+ 'pypy -> publish to pypy' ,
2196+ 'docs -> let me overwrite that' ]
22052197
22062198 def test_listenvs_all (self , cmd , initproj ):
22072199 initproj ('listenvs_all' , filedefs = {
@@ -2216,15 +2208,8 @@ def test_listenvs_all(self, cmd, initproj):
22162208 changedir = docs
22172209 '''
22182210 })
2219- result = cmd .run ("tox" , "-a" )
2220- result .stdout .fnmatch_lines ("""
2221- py36
2222- py27
2223- py34
2224- pypy
2225- docs
2226- notincluded
2227- """ )
2211+ result = cmd ("-a" )
2212+ assert result .outlines == ['py36' , 'py27' , 'py34' , 'pypy' , 'docs' , 'notincluded' ]
22282213
22292214 def test_listenvs_all_verbose_description (self , cmd , initproj ):
22302215 initproj ('listenvs_all_verbose_description' , filedefs = {
@@ -2241,19 +2226,19 @@ def test_listenvs_all_verbose_description(self, cmd, initproj):
22412226
22422227 [testenv:docs]
22432228 changedir = docs
2244- '''
2229+ ''' ,
22452230 })
2246- result = cmd . run ( "tox" , "-av" )
2247- result . stdout . fnmatch_lines ( """
2248- default environments:
2249- py27-windows -> run pytest on Python 2.7 on Windows platform
2250- py27-linux -> run pytest on Python 2.7 on Linux platform
2251- py36-windows -> run pytest on Python 3.6 on Windows platform
2252- py36-linux -> run pytest on Python 3.6 on Linux platform
2253-
2254- additional environments:
2255- docs -> generate documentation
2256- """ )
2231+ result = cmd ( "-av" )
2232+ expected = [
2233+ " default environments:" ,
2234+ " py27-windows -> run pytest on Python 2.7 on Windows platform" ,
2235+ " py27-linux -> run pytest on Python 2.7 on Linux platform" ,
2236+ " py36-windows -> run pytest on Python 3.6 on Windows platform" ,
2237+ " py36-linux -> run pytest on Python 3.6 on Linux platform" ,
2238+ "" ,
2239+ " additional environments:" ,
2240+ " docs -> generate documentation" ]
2241+ assert result . outlines [ - len ( expected ):] == expected
22572242
22582243 def test_listenvs_all_verbose_description_no_additional_environments (self , cmd , initproj ):
22592244 initproj ('listenvs_all_verbose_description' , filedefs = {
@@ -2262,29 +2247,25 @@ def test_listenvs_all_verbose_description_no_additional_environments(self, cmd,
22622247 envlist=py27,py36
22632248 '''
22642249 })
2265- result = cmd .run ("tox" , "-av" )
2266- result .stdout .fnmatch_lines ("""
2267- default environments:
2268- py27 -> [no description]
2269- py36 -> [no description]
2270- """ )
2271- assert 'additional environments' not in result .stdout .str ()
2250+ result = cmd ("-av" )
2251+ expected = ["default environments:" ,
2252+ "py27 -> [no description]" ,
2253+ "py36 -> [no description]" ]
2254+ assert result .out .splitlines ()[- 3 :] == expected
2255+ assert 'additional environments' not in result .out
22722256
22732257 def test_config_specific_ini (self , tmpdir , cmd ):
22742258 ini = tmpdir .ensure ("hello.ini" )
2275- result = cmd . run ( "tox" , "-c" , ini , "--showconfig" )
2259+ result = cmd ( "-c" , ini , "--showconfig" )
22762260 assert not result .ret
2277- result .stdout .fnmatch_lines ([
2278- "*config-file*hello.ini*"
2279- ])
2261+ assert result .outlines [1 ] == 'config-file: {}' .format (ini )
22802262
22812263 def test_no_tox_ini (self , cmd , initproj ):
2282- initproj ("noini-0.5" )
2283- result = cmd . run ( "tox" )
2264+ initproj ("noini-0.5" , )
2265+ result = cmd ( )
22842266 assert result .ret
2285- result .stderr .fnmatch_lines ([
2286- "*ERROR*tox.ini*not*found*"
2287- ])
2267+ assert result .out == ''
2268+ assert result .err == "ERROR: toxini file 'tox.ini' not found\n "
22882269
22892270 def test_override_workdir (self , tmpdir , cmd , initproj ):
22902271 baddir = "badworkdir-123"
@@ -2293,13 +2274,12 @@ def test_override_workdir(self, tmpdir, cmd, initproj):
22932274 'tox.ini' : '''
22942275 [tox]
22952276 toxworkdir=%s
2296- ''' % baddir
2277+ ''' % baddir ,
22972278 })
2298- result = cmd . run ( "tox" , "--workdir" , gooddir , "--showconfig" )
2279+ result = cmd ( "--workdir" , gooddir , "--showconfig" )
22992280 assert not result .ret
2300- stdout = result .stdout .str ()
2301- assert gooddir in stdout
2302- assert baddir not in stdout
2281+ assert gooddir in result .out
2282+ assert baddir not in result .out
23032283 assert py .path .local (gooddir ).check ()
23042284 assert not py .path .local (baddir ).check ()
23052285
@@ -2312,20 +2292,16 @@ def test_showconfig_with_force_dep_version(self, cmd, initproj):
23122292 deps=
23132293 dep1==2.3
23142294 dep2
2315- '''
2295+ ''' ,
23162296 })
2317- result = cmd . run ( "tox" , "--showconfig" )
2297+ result = cmd ( "--showconfig" )
23182298 assert result .ret == 0
2319- result .stdout .fnmatch_lines ([
2320- r'*deps*dep1==2.3, dep2*'
2321- ])
2299+ assert any (re .match (r'.*deps.*dep1==2.3, dep2.*' , l ) for l in result .outlines )
23222300 # override dep1 specific version, and force version for dep2
2323- result = cmd . run ( "tox" , "--showconfig" , "--force-dep=dep1" ,
2324- "--force-dep=dep2==5.0" )
2301+ result = cmd ( "--showconfig" , "--force-dep=dep1" ,
2302+ "--force-dep=dep2==5.0" )
23252303 assert result .ret == 0
2326- result .stdout .fnmatch_lines ([
2327- r'*deps*dep1, dep2==5.0*'
2328- ])
2304+ assert any (re .match (r'.*deps.*dep1, dep2==5.0.*' , l ) for l in result .outlines )
23292305
23302306 @pytest .mark .xfail (
23312307 "'pypy' not in sys.executable" ,
@@ -2340,7 +2316,7 @@ def test_colon_symbol_in_directory_name(self, cmd, initproj):
23402316 commands = pip --version
23412317 '''
23422318 })
2343- result = cmd . run ( "tox" )
2319+ result = cmd ( )
23442320 assert result .ret == 0
23452321
23462322
0 commit comments