Skip to content

Commit 306d963

Browse files
committed
Prefix fixture with jp
1 parent cc551fa commit 306d963

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

jupyter_server/tests/services/contents/test_manager.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def jp_contents_manager(request, tmp_path):
2323

2424

2525
@pytest.fixture(params=[FileContentsManager, AsyncFileContentsManager])
26-
def file_contents_manager_class(request, tmp_path):
26+
def jp_file_contents_manager_class(request, tmp_path):
2727
return request.param
2828

2929
# -------------- Functions ----------------------------
@@ -100,46 +100,45 @@ async def check_populated_dir_files(jp_contents_manager, api_path):
100100
# ----------------- Tests ----------------------------------
101101

102102

103-
def test_root_dir(file_contents_manager_class, tmp_path):
104-
fm = file_contents_manager_class(root_dir=str(tmp_path))
103+
def test_root_dir(jp_file_contents_manager_class, tmp_path):
104+
fm = jp_file_contents_manager_class(root_dir=str(tmp_path))
105105
assert fm.root_dir == str(tmp_path)
106106

107107

108-
def test_missing_root_dir(file_contents_manager_class, tmp_path):
108+
def test_missing_root_dir(jp_file_contents_manager_class, tmp_path):
109109
root = tmp_path / 'notebook' / 'dir' / 'is' / 'missing'
110110
with pytest.raises(TraitError):
111-
file_contents_manager_class(root_dir=str(root))
111+
jp_file_contents_manager_class(root_dir=str(root))
112112

113113

114-
def test_invalid_root_dir(file_contents_manager_class, tmp_path):
114+
def test_invalid_root_dir(jp_file_contents_manager_class, tmp_path):
115115
temp_file = tmp_path / 'file.txt'
116116
temp_file.write_text('')
117117
with pytest.raises(TraitError):
118-
file_contents_manager_class(root_dir=str(temp_file))
118+
jp_file_contents_manager_class(root_dir=str(temp_file))
119119

120-
121-
def test_get_os_path(file_contents_manager_class, tmp_path):
122-
fm = file_contents_manager_class(root_dir=str(tmp_path))
120+
def test_get_os_path(jp_file_contents_manager_class, tmp_path):
121+
fm = jp_file_contents_manager_class(root_dir=str(tmp_path))
123122
path = fm._get_os_path('/path/to/notebook/test.ipynb')
124123
rel_path_list = '/path/to/notebook/test.ipynb'.split('/')
125124
fs_path = os.path.join(fm.root_dir, *rel_path_list)
126125
assert path == fs_path
127126

128-
fm = file_contents_manager_class(root_dir=str(tmp_path))
127+
fm = jp_file_contents_manager_class(root_dir=str(tmp_path))
129128
path = fm._get_os_path('test.ipynb')
130129
fs_path = os.path.join(fm.root_dir, 'test.ipynb')
131130
assert path == fs_path
132131

133-
fm = file_contents_manager_class(root_dir=str(tmp_path))
132+
fm = jp_file_contents_manager_class(root_dir=str(tmp_path))
134133
path = fm._get_os_path('////test.ipynb')
135134
fs_path = os.path.join(fm.root_dir, 'test.ipynb')
136135
assert path == fs_path
137136

138137

139-
def test_checkpoint_subdir(file_contents_manager_class, tmp_path):
138+
def test_checkpoint_subdir(jp_file_contents_manager_class, tmp_path):
140139
subd = 'sub ∂ir'
141140
cp_name = 'test-cp.ipynb'
142-
fm = file_contents_manager_class(root_dir=str(tmp_path))
141+
fm = jp_file_contents_manager_class(root_dir=str(tmp_path))
143142
tmp_path.joinpath(subd).mkdir()
144143
cpm = fm.checkpoints
145144
cp_dir = cpm.checkpoint_path('cp', 'test.ipynb')
@@ -148,10 +147,10 @@ def test_checkpoint_subdir(file_contents_manager_class, tmp_path):
148147
assert cp_dir == os.path.join(str(tmp_path), cpm.checkpoint_dir, cp_name)
149148

150149

151-
async def test_bad_symlink(file_contents_manager_class, tmp_path):
150+
async def test_bad_symlink(jp_file_contents_manager_class, tmp_path):
152151
td = str(tmp_path)
153152

154-
cm = file_contents_manager_class(root_dir=td)
153+
cm = jp_file_contents_manager_class(root_dir=td)
155154
path = 'test bad symlink'
156155
_make_dir(cm, path)
157156

@@ -173,10 +172,10 @@ async def test_bad_symlink(file_contents_manager_class, tmp_path):
173172
sys.platform.startswith('win'),
174173
reason="Windows doesn't detect symlink loops"
175174
)
176-
async def test_recursive_symlink(file_contents_manager_class, tmp_path):
175+
async def test_recursive_symlink(jp_file_contents_manager_class, tmp_path):
177176
td = str(tmp_path)
178177

179-
cm = file_contents_manager_class(root_dir=td)
178+
cm = jp_file_contents_manager_class(root_dir=td)
180179
path = 'test recursive symlink'
181180
_make_dir(cm, path)
182181

@@ -195,9 +194,9 @@ async def test_recursive_symlink(file_contents_manager_class, tmp_path):
195194
assert 'recursive' not in contents
196195

197196

198-
async def test_good_symlink(file_contents_manager_class, tmp_path):
197+
async def test_good_symlink(jp_file_contents_manager_class, tmp_path):
199198
td = str(tmp_path)
200-
cm = file_contents_manager_class(root_dir=td)
199+
cm = jp_file_contents_manager_class(root_dir=td)
201200
parent = 'test good symlink'
202201
name = 'good symlink'
203202
path = '{0}/{1}'.format(parent, name)
@@ -216,13 +215,13 @@ async def test_good_symlink(file_contents_manager_class, tmp_path):
216215
sys.platform.startswith('win'),
217216
reason="Can't test permissions on Windows"
218217
)
219-
async def test_403(file_contents_manager_class, tmp_path):
218+
async def test_403(jp_file_contents_manager_class, tmp_path):
220219
if hasattr(os, 'getuid'):
221220
if os.getuid() == 0:
222221
raise pytest.skip("Can't test permissions as root")
223222

224223
td = str(tmp_path)
225-
cm = file_contents_manager_class(root_dir=td)
224+
cm = jp_file_contents_manager_class(root_dir=td)
226225
model = await ensure_async(cm.new_untitled(type='file'))
227226
os_path = cm._get_os_path(model['path'])
228227

@@ -233,10 +232,9 @@ async def test_403(file_contents_manager_class, tmp_path):
233232
except HTTPError as e:
234233
assert e.status_code == 403
235234

236-
237-
async def test_escape_root(file_contents_manager_class, tmp_path):
235+
async def test_escape_root(jp_file_contents_manager_class, tmp_path):
238236
td = str(tmp_path)
239-
cm = file_contents_manager_class(root_dir=td)
237+
cm = jp_file_contents_manager_class(root_dir=td)
240238
# make foo, bar next to root
241239
with open(os.path.join(cm.root_dir, '..', 'foo'), 'w') as f:
242240
f.write('foo')

0 commit comments

Comments
 (0)