Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f7fd98

Browse files
committed
reformat all the tests
1 parent 34f3cb7 commit 1f7fd98

59 files changed

Lines changed: 2224 additions & 1545 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/bad_all.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
To test https://github.com/ipython/ipython/issues/9678
44
"""
55

6+
67
def evil():
78
pass
89

10+
911
def puppies():
1012
pass
1113

12-
__all__ = [evil, # Bad
13-
'puppies', # Good
14-
]
14+
15+
__all__ = [
16+
evil, # Bad
17+
"puppies", # Good
18+
]

tests/fake_ext_dir/daft_extension.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"""
33
Useless IPython extension to test installing and loading extensions.
44
"""
5-
some_vars = {'arq': 185}
5+
some_vars = {"arq": 185}
6+
67

78
def load_ipython_extension(ip):
89
# set up simplified quantity input
910
ip.push(some_vars)
1011

12+
1113
def unload_ipython_extension(ip):
1214
ip.drop_by_id(some_vars)

tests/refbug.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,34 @@
1313
test_run.py calls it.
1414
"""
1515

16-
#-----------------------------------------------------------------------------
16+
# -----------------------------------------------------------------------------
1717
# Module imports
18-
#-----------------------------------------------------------------------------
18+
# -----------------------------------------------------------------------------
1919

2020
from IPython import get_ipython
2121

22-
#-----------------------------------------------------------------------------
22+
# -----------------------------------------------------------------------------
2323
# Globals
24-
#-----------------------------------------------------------------------------
24+
# -----------------------------------------------------------------------------
2525

2626
# This needs to be here because nose and other test runners will import
2727
# this module. Importing this module has potential side effects that we
2828
# want to prevent.
29-
if __name__ == '__main__':
29+
if __name__ == "__main__":
3030

3131
ip = get_ipython()
3232

33-
if not '_refbug_cache' in ip.user_ns:
34-
ip.user_ns['_refbug_cache'] = []
33+
if not "_refbug_cache" in ip.user_ns:
34+
ip.user_ns["_refbug_cache"] = []
3535

36+
aglobal = "Hello"
3637

37-
aglobal = 'Hello'
3838
def f():
3939
return aglobal
4040

41-
cache = ip.user_ns['_refbug_cache']
41+
cache = ip.user_ns["_refbug_cache"]
4242
cache.append(f)
4343

4444
def call_f():
4545
for func in cache:
46-
print('lowercased:',func().lower())
46+
print("lowercased:", func().lower())

tests/tclass.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@
22
33
See test_run for details."""
44

5-
65
import sys
76

7+
88
# We want to ensure that while objects remain available for immediate access,
99
# objects from *previous* runs of the same script get collected, to avoid
1010
# accumulating massive amounts of old references.
1111
class C(object):
12-
def __init__(self,name):
12+
def __init__(self, name):
1313
self.name = name
1414
self.p = print
1515
self.flush_stdout = sys.stdout.flush
16-
16+
1717
def __del__(self):
18-
self.p('tclass.py: deleting object:',self.name)
18+
self.p("tclass.py: deleting object:", self.name)
1919
self.flush_stdout()
2020

21+
2122
try:
2223
name = sys.argv[1]
2324
except IndexError:
2425
pass
2526
else:
26-
if name.startswith('C'):
27+
if name.startswith("C"):
2728
c = C(name)
2829

2930
# print("ARGV:", sys.argv, file=sys.stderr) # dbg
3031

3132
# This next print statement is NOT debugging, we're making the check on a
3233
# completely separate process so we verify by capturing stdout:
33-
print('ARGV 1-:', sys.argv[1:])
34+
print("ARGV 1-:", sys.argv[1:])
3435
sys.stdout.flush()

tests/test_alias.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,42 @@
22

33
import pytest
44

5+
56
def test_alias_lifecycle():
6-
name = 'test_alias1'
7+
name = "test_alias1"
78
cmd = 'echo "Hello"'
89
am = _ip.alias_manager
910
am.clear_aliases()
1011
am.define_alias(name, cmd)
1112
assert am.is_alias(name)
1213
assert am.retrieve_alias(name) == cmd
1314
assert (name, cmd) in am.aliases
14-
15+
1516
# Test running the alias
1617
orig_system = _ip.system
1718
result = []
1819
_ip.system = result.append
1920
try:
20-
_ip.run_cell('%{}'.format(name))
21+
_ip.run_cell("%{}".format(name))
2122
result = [c.strip() for c in result]
2223
assert result == [cmd]
2324
finally:
2425
_ip.system = orig_system
25-
26+
2627
# Test removing the alias
2728
am.undefine_alias(name)
2829
assert not am.is_alias(name)
2930
with pytest.raises(ValueError):
3031
am.retrieve_alias(name)
3132
assert (name, cmd) not in am.aliases
32-
33+
3334

3435
def test_alias_args_error():
3536
"""Error expanding with wrong number of arguments"""
36-
_ip.alias_manager.define_alias('parts', 'echo first %s second %s')
37+
_ip.alias_manager.define_alias("parts", "echo first %s second %s")
3738
# capture stderr:
3839
with capture_output() as cap:
39-
_ip.run_cell('parts 1')
40+
_ip.run_cell("parts 1")
4041

4142
assert cap.stderr.split(":")[0] == "UsageError"
4243

@@ -51,16 +52,17 @@ def test_alias_args_commented():
5152
# strip() is for pytest compat; testing via iptest patch IPython shell
5253
# in testing.globalipapp and replace the system call which messed up the
5354
# \r\n
54-
assert cap.stdout.strip() == 'this is %s a commented out arg'
55+
assert cap.stdout.strip() == "this is %s a commented out arg"
56+
5557

5658
def test_alias_args_commented_nargs():
5759
"""Check that alias correctly counts args, excluding those commented out"""
5860
am = _ip.alias_manager
59-
alias_name = 'comargcount'
60-
cmd = 'echo this is %%s a commented out arg and this is not %s'
61-
61+
alias_name = "comargcount"
62+
cmd = "echo this is %%s a commented out arg and this is not %s"
63+
6264
am.define_alias(alias_name, cmd)
6365
assert am.is_alias(alias_name)
64-
66+
6567
thealias = am.get_alias(alias_name)
6668
assert thealias.nargs == 1

tests/test_application.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
@dec.onlyif_unicode_paths
1515
def test_unicode_cwd():
1616
"""Check that IPython starts with non-ascii characters in the path."""
17-
wd = tempfile.mkdtemp(suffix=u"€")
18-
17+
wd = tempfile.mkdtemp(suffix="€")
18+
1919
old_wd = os.getcwd()
2020
os.chdir(wd)
21-
#raise Exception(repr(os.getcwd()))
21+
# raise Exception(repr(os.getcwd()))
2222
try:
2323
app = BaseIPythonApplication()
2424
# The lines below are copied from Application.initialize()
@@ -28,15 +28,16 @@ def test_unicode_cwd():
2828
finally:
2929
os.chdir(old_wd)
3030

31+
3132
@dec.onlyif_unicode_paths
3233
def test_unicode_ipdir():
3334
"""Check that IPython starts with non-ascii characters in the IP dir."""
34-
ipdir = tempfile.mkdtemp(suffix=u"€")
35-
35+
ipdir = tempfile.mkdtemp(suffix="€")
36+
3637
# Create the config file, so it tries to load it.
3738
with open(os.path.join(ipdir, "ipython_config.py"), "w", encoding="utf-8") as f:
3839
pass
39-
40+
4041
old_ipdir1 = os.environ.pop("IPYTHONDIR", None)
4142
old_ipdir2 = os.environ.pop("IPYTHON_DIR", None)
4243
os.environ["IPYTHONDIR"] = ipdir
@@ -52,6 +53,7 @@ def test_unicode_ipdir():
5253
if old_ipdir2:
5354
os.environ["IPYTHONDIR"] = old_ipdir2
5455

56+
5557
def test_cli_priority():
5658
with TemporaryDirectory() as td:
5759

0 commit comments

Comments
 (0)