Skip to content

Commit bbbf5e2

Browse files
jurko-gospodneticgaborbernat
authored andcommitted
code cleanup (tox-dev#705)
* remove trailing list/tuple commas * improve initproj() docstring
1 parent 837fbb5 commit bbbf5e2

File tree

2 files changed

+42
-19
lines changed

2 files changed

+42
-19
lines changed

tests/test_config.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_force_dep_version(self, initproj):
9595
assert config.option.force_dep == [
9696
'dep1==1.5', 'dep2==2.1', 'dep3==3.0']
9797
assert [str(x) for x in config.envconfigs['python'].deps] == [
98-
'dep1==1.5', 'dep2==2.1', 'dep3==3.0', 'dep4==4.0',
98+
'dep1==1.5', 'dep2==2.1', 'dep3==3.0', 'dep4==4.0'
9999
]
100100

101101
def test_force_dep_with_url(self, initproj):
@@ -313,7 +313,7 @@ def test_command_substitution_from_other_section_multiline(self, newconfig):
313313
"cmd2 param21 param22".split(),
314314
"cmd1 param11 param12".split(),
315315
"cmd2 param21 param22".split(),
316-
["echo", "cmd", "1", "2", "3", "4", "cmd", "2"],
316+
["echo", "cmd", "1", "2", "3", "4", "cmd", "2"]
317317
]
318318

319319
def test_command_substitution_from_other_section_posargs(self, newconfig):
@@ -1137,7 +1137,7 @@ def test_substitution_notfound_issue515(tmpdir, newconfig):
11371137
""")
11381138
conf = config.envconfigs['standard-greeting']
11391139
assert conf.commands == [
1140-
['python', '-c', 'print("Hello, world!")'],
1140+
['python', '-c', 'print("Hello, world!")']
11411141
]
11421142

11431143
def test_substitution_nested_env_defaults(tmpdir, newconfig, monkeypatch):
@@ -1268,7 +1268,7 @@ def test_rewrite_simple_posargs(self, tmpdir, newconfig):
12681268

12691269
@pytest.mark.parametrize('envlist, deps', [
12701270
(['py27'], ('pytest', 'pytest-cov')),
1271-
(['py27', 'py34'], ('pytest', 'py{27,34}: pytest-cov')),
1271+
(['py27', 'py34'], ('pytest', 'py{27,34}: pytest-cov'))
12721272
])
12731273
def test_take_dependencies_from_other_testenv(
12741274
self,
@@ -2078,7 +2078,7 @@ def test_help(self, cmd):
20782078
result = cmd.run("tox", "-h")
20792079
assert not result.ret
20802080
result.stdout.fnmatch_lines([
2081-
"*help*",
2081+
"*help*"
20822082
])
20832083

20842084
def test_version_simple(self, cmd):
@@ -2151,7 +2151,7 @@ def test_listenvs(self, cmd, initproj):
21512151
21522152
[testenv:docs]
21532153
changedir = docs
2154-
''',
2154+
'''
21552155
})
21562156
result = cmd.run("tox", "-l")
21572157
result.stdout.fnmatch_lines("""
@@ -2181,7 +2181,7 @@ def test_listenvs_verbose_description(self, cmd, initproj):
21812181
[testenv:docs]
21822182
changedir = docs
21832183
description = let me overwrite that
2184-
''',
2184+
'''
21852185
})
21862186
result = cmd.run("tox", "-lv")
21872187
result.stdout.fnmatch_lines("""
@@ -2204,7 +2204,7 @@ def test_listenvs_all(self, cmd, initproj):
22042204
22052205
[testenv:docs]
22062206
changedir = docs
2207-
''',
2207+
'''
22082208
})
22092209
result = cmd.run("tox", "-a")
22102210
result.stdout.fnmatch_lines("""
@@ -2231,7 +2231,7 @@ def test_listenvs_all_verbose_description(self, cmd, initproj):
22312231
22322232
[testenv:docs]
22332233
changedir = docs
2234-
''',
2234+
'''
22352235
})
22362236
result = cmd.run("tox", "-av")
22372237
result.stdout.fnmatch_lines("""
@@ -2250,7 +2250,7 @@ def test_listenvs_all_verbose_description_no_additional_environments(self, cmd,
22502250
'tox.ini': '''
22512251
[tox]
22522252
envlist=py27,py36
2253-
''',
2253+
'''
22542254
})
22552255
result = cmd.run("tox", "-av")
22562256
result.stdout.fnmatch_lines("""
@@ -2265,15 +2265,15 @@ def test_config_specific_ini(self, tmpdir, cmd):
22652265
result = cmd.run("tox", "-c", ini, "--showconfig")
22662266
assert not result.ret
22672267
result.stdout.fnmatch_lines([
2268-
"*config-file*hello.ini*",
2268+
"*config-file*hello.ini*"
22692269
])
22702270

22712271
def test_no_tox_ini(self, cmd, initproj):
22722272
initproj("noini-0.5")
22732273
result = cmd.run("tox")
22742274
assert result.ret
22752275
result.stderr.fnmatch_lines([
2276-
"*ERROR*tox.ini*not*found*",
2276+
"*ERROR*tox.ini*not*found*"
22772277
])
22782278

22792279
def test_override_workdir(self, tmpdir, cmd, initproj):
@@ -2283,7 +2283,7 @@ def test_override_workdir(self, tmpdir, cmd, initproj):
22832283
'tox.ini': '''
22842284
[tox]
22852285
toxworkdir=%s
2286-
''' % baddir,
2286+
''' % baddir
22872287
})
22882288
result = cmd.run("tox", "--workdir", gooddir, "--showconfig")
22892289
assert not result.ret
@@ -2302,19 +2302,19 @@ def test_showconfig_with_force_dep_version(self, cmd, initproj):
23022302
deps=
23032303
dep1==2.3
23042304
dep2
2305-
''',
2305+
'''
23062306
})
23072307
result = cmd.run("tox", "--showconfig")
23082308
assert result.ret == 0
23092309
result.stdout.fnmatch_lines([
2310-
r'*deps*dep1==2.3, dep2*',
2310+
r'*deps*dep1==2.3, dep2*'
23112311
])
23122312
# override dep1 specific version, and force version for dep2
23132313
result = cmd.run("tox", "--showconfig", "--force-dep=dep1",
23142314
"--force-dep=dep2==5.0")
23152315
assert result.ret == 0
23162316
result.stdout.fnmatch_lines([
2317-
r'*deps*dep1, dep2==5.0*',
2317+
r'*deps*dep1, dep2==5.0*'
23182318
])
23192319

23202320
@pytest.mark.xfail(
@@ -2328,7 +2328,7 @@ def test_colon_symbol_in_directory_name(self, cmd, initproj):
23282328
23292329
[testenv]
23302330
commands = pip --version
2331-
''',
2331+
'''
23322332
})
23332333
result = cmd.run("tox")
23342334
assert result.ret == 0
@@ -2374,7 +2374,7 @@ def test_command_parser_with_complex_word_set(self):
23742374
'word', ' ', '[]', ' ', '[literal]', ' ', '{something}', ' ', '{some:other thing}',
23752375
' ', 'w', '{ord}', ' ', 'w', '{or}', 'd', ' ', 'w', '{ord}', ' ', 'w', '{o:rd}', ' ',
23762376
'w', '{o:r}', 'd', ' ', '{w:or}', 'd',
2377-
' ', 'w[]ord', ' ', '{posargs:{a key}}',
2377+
' ', 'w[]ord', ' ', '{posargs:{a key}}'
23782378
]
23792379

23802380
assert parsed == expected

tox/_pytestplugin.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,30 @@ def fnmatch_lines(self, lines2):
291291

292292
@pytest.fixture
293293
def initproj(request, tmpdir):
294-
""" create a factory function for creating example projects. """
294+
"""Create a factory function for creating example projects
295+
296+
Constructed folder/file hierarchy examples:
297+
298+
with `src_root` other than `.`:
299+
300+
tmpdir/
301+
name/ # base
302+
src_root/ # src_root
303+
name/ # package_dir
304+
__init__.py
305+
name.egg-info/ # created later on package build
306+
setup.py
307+
308+
with `src_root` given as `.`:
309+
310+
tmpdir/
311+
name/ # base, src_root
312+
name/ # package_dir
313+
__init__.py
314+
name.egg-info/ # created later on package build
315+
setup.py
316+
317+
"""
295318
def initproj(nameversion, filedefs=None, src_root="."):
296319
if filedefs is None:
297320
filedefs = {}

0 commit comments

Comments
 (0)