Skip to content

Commit e7002ac

Browse files
committed
More CodeQL corrections
1 parent e394bdc commit e7002ac

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

tests/nbconvert/test_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
@pytest.fixture
2828
def notebook(jp_root_dir):
2929
# Build sub directory.
30+
subdir = jp_root_dir / 'foo'
3031
if not jp_root_dir.joinpath('foo').is_dir():
31-
subdir = jp_root_dir / 'foo'
3232
subdir.mkdir()
3333

3434
# Build a notebook programmatically.

tests/services/contents/test_api.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async def test_get_dir_no_contents(jp_fetch, contents, path, name):
100100
assert model['path'] == path
101101
assert model['type'] == 'directory'
102102
assert 'content' in model
103-
assert model['content'] == None
103+
assert model['content'] is None
104104

105105

106106
async def test_list_nonexistant_dir(jp_fetch, contents):
@@ -144,7 +144,7 @@ async def test_get_nb_no_contents(jp_fetch, contents, path, name):
144144
assert model['path'] == nbpath
145145
assert model['type'] == 'notebook'
146146
assert 'content' in model
147-
assert model['content'] == None
147+
assert model['content'] is None
148148

149149

150150
async def test_get_nb_invalid(contents_dir, jp_fetch, contents):
@@ -623,7 +623,7 @@ async def test_checkpoints_follow_file(jp_fetch, contents):
623623
hcell = new_markdown_cell('Created by test')
624624
nb.cells.append(hcell)
625625
nbmodel = {'content': nb, 'type': 'notebook'}
626-
r = await jp_fetch(
626+
await jp_fetch(
627627
'api', 'contents', path, name,
628628
method='PUT',
629629
body=json.dumps(nbmodel)
@@ -653,7 +653,7 @@ async def test_rename_existing(jp_fetch, contents):
653653
name = 'a.ipynb'
654654
new_name = 'b.ipynb'
655655
# Rename the file
656-
r = await jp_fetch(
656+
await jp_fetch(
657657
'api', 'contents', path, name,
658658
method='PATCH',
659659
body=json.dumps({'path': path+'/'+new_name})
@@ -671,7 +671,7 @@ async def test_save(jp_fetch, contents):
671671
nb = from_dict(nbmodel)
672672
nb.cells.append(new_markdown_cell('Created by test ³'))
673673
nbmodel = {'content': nb, 'type': 'notebook'}
674-
r = await jp_fetch(
674+
await jp_fetch(
675675
'api', 'contents', 'foo/a.ipynb',
676676
method='PUT',
677677
body=json.dumps(nbmodel)
@@ -711,7 +711,7 @@ async def test_checkpoints(jp_fetch, contents):
711711

712712
# Save it.
713713
nbmodel = {'content': nb, 'type': 'notebook'}
714-
resp = await jp_fetch(
714+
await jp_fetch(
715715
'api', 'contents', path,
716716
method='PUT',
717717
body=json.dumps(nbmodel)
@@ -790,7 +790,7 @@ async def test_file_checkpoints(jp_fetch, contents):
790790
}
791791

792792
# Save it.
793-
resp = await jp_fetch(
793+
await jp_fetch(
794794
'api', 'contents', path,
795795
method='PUT',
796796
body=json.dumps(model)

tests/services/kernels/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def test_kernel_handler(jp_fetch):
159159
# Requests a bad kernel id.
160160
bad_id = '111-111-111-111-111'
161161
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
162-
r = await jp_fetch(
162+
await jp_fetch(
163163
'api', 'kernels', bad_id,
164164
method='GET'
165165
)

tests/services/nbconvert/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22

3+
34
async def test_list_formats(jp_fetch):
45
r = await jp_fetch(
56
'api', 'nbconvert',

tests/test_files.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def test_hidden_files(jp_fetch, jp_serverapp, jp_root_dir):
3535
assert r.body.decode() == 'foo'
3636

3737
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
38-
r = await jp_fetch(
38+
await jp_fetch(
3939
'files', d, '.foo',
4040
method='GET'
4141
)
@@ -44,7 +44,7 @@ async def test_hidden_files(jp_fetch, jp_serverapp, jp_root_dir):
4444
for d in hidden:
4545
for foo in ('foo', '.foo'):
4646
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
47-
r = await jp_fetch(
47+
await jp_fetch(
4848
'files', d, foo,
4949
method='GET'
5050
)
@@ -75,7 +75,7 @@ async def test_hidden_files(jp_fetch, jp_serverapp, jp_root_dir):
7575

7676

7777
async def test_contents_manager(jp_fetch, jp_serverapp, jp_root_dir):
78-
"make sure ContentsManager returns right files (ipynb, bin, txt)."
78+
"""make sure ContentsManager returns right files (ipynb, bin, txt)."""
7979
nb = new_notebook(
8080
cells=[
8181
new_markdown_cell(u'Created by test ³'),
@@ -139,7 +139,6 @@ async def test_old_files_redirect(jp_fetch, jp_serverapp, jp_root_dir):
139139
jp_root_dir.joinpath('files').mkdir(parents=True, exist_ok=True)
140140
jp_root_dir.joinpath('sub', 'files').mkdir(parents=True, exist_ok=True)
141141

142-
143142
for prefix in ('', 'sub'):
144143
jp_root_dir.joinpath(prefix, 'files', 'f1.txt').write_text(prefix + '/files/f1')
145144
jp_root_dir.joinpath(prefix, 'files', 'f2.txt').write_text(prefix + '/files/f2')

0 commit comments

Comments
 (0)