Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pathlib instead of os.path.join in tests/conftest.py #6624

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import json
import os
import os.path as osp
import pathlib
import shutil
from importlib.resources import files
from os.path import join as pjoin

import pytest

Expand Down Expand Up @@ -89,37 +89,37 @@ def _make_notebook_app(**kwargs):

# Copy the schema files.
test_data = str(files("jupyterlab_server.test_data").joinpath(""))
src = pjoin(test_data, "schemas", "@jupyterlab")
dst = pjoin(str(schemas_dir), "@jupyterlab")
src = pathlib.PurePath(test_data, "schemas", "@jupyterlab")
dst = pathlib.PurePath(str(schemas_dir), "@jupyterlab")
if os.path.exists(dst):
shutil.rmtree(dst)
shutil.copytree(src, dst)

# Create the federated extensions
for name in ["apputils-extension", "codemirror-extension"]:
target_name = name + "-federated"
target = pjoin(str(labextensions_dir), "@jupyterlab", target_name)
src = pjoin(test_data, "schemas", "@jupyterlab", name)
dst = pjoin(target, "schemas", "@jupyterlab", target_name)
target = pathlib.PurePath(str(labextensions_dir), "@jupyterlab", target_name)
src = pathlib.PurePath(test_data, "schemas", "@jupyterlab", name)
dst = target / "schemas" / "@jupyterlab" / target_name
if osp.exists(dst):
shutil.rmtree(dst)
shutil.copytree(src, dst)
with open(pjoin(target, "package.orig.json"), "w") as fid:
with open(target / "package.orig.json", "w") as fid:
data = dict(name=target_name, jupyterlab=dict(extension=True))
json.dump(data, fid)

# Copy the overrides file.
src = pjoin(test_data, "app-settings", "overrides.json")
dst = pjoin(str(app_settings_dir), "overrides.json")
src = pathlib.PurePath(test_data, "app-settings", "overrides.json")
dst = pathlib.PurePath(str(app_settings_dir), "overrides.json")
if os.path.exists(dst):
os.remove(dst)
shutil.copyfile(src, dst)

# Copy workspaces.
data = pjoin(test_data, "workspaces")
data = pathlib.PurePath(test_data, "workspaces")
for item in os.listdir(data):
src = pjoin(data, item)
dst = pjoin(str(workspaces_dir), item)
src = data / item
dst = pathlib.PurePath(str(workspaces_dir), item)
if os.path.exists(dst):
os.remove(dst)
shutil.copy(src, str(workspaces_dir))
Expand Down