Skip to content

Commit

Permalink
Set the env variable in package.json instead of task.py, to simplify …
Browse files Browse the repository at this point in the history
…local tests
  • Loading branch information
brichet committed Jun 20, 2024
1 parent d878f23 commit 0230bbf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@
if not os.path.isdir(env["NBGRADER_TEST_DIR"]):
raise Exception(f"Test directory {env['NBGRADER_TEST_DIR']} doesn't exists")

shutil.copyfile("./nbgrader/tests/ui-tests/utils/jupyter_server_config_notebook.py",
join(root_dir, "jupyter_server_config_notebook.py"))
subprocess.check_call([sys.executable, "-m", "jupyter", "server", "extension", "enable", "--user", "--py", "nbgrader"], env=env)
subprocess.check_call([sys.executable, "-m", "jupyter", "labextension", "develop", "--overwrite", "."])

shutil.copyfile("./nbgrader/tests/ui-tests/files/nbgrader_config.py",
join(root_dir, "nbgrader_config.py"))

subprocess.check_call([sys.executable, "-m", "jupyter", "server", "extension", "enable", "--user", "--py", "nbgrader"], env=env)
subprocess.check_call([sys.executable, "-m", "jupyter", "labextension", "develop", "--overwrite", "."])
if "NBGRADER_TEST_IS_NOTEBOOK" in env.keys():
shutil.copyfile("./nbgrader/tests/ui-tests/utils/jupyter_server_config_notebook.py",
join(root_dir, "jupyter_server_config_notebook.py"))
command = ["jupyter", "notebook", "--config", "./jupyter_server_config_notebook.py"]
else:
shutil.copyfile("./nbgrader/tests/ui-tests/utils/jupyter_server_config.py",
join(root_dir, "jupyter_server_config.py"))
command = ["jupyter", "lab", "--config", "./jupyter_server_config.py"]

os.chdir(root_dir)

command = ["jupyter", "notebook", "--config", "./jupyter_server_config_notebook.py"]
subprocess.run(command)
27 changes: 0 additions & 27 deletions nbgrader/tests/ui-tests/utils/run_jupyter_lab.py

This file was deleted.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
"clean:labextension": "rimraf nbgrader/labextension",
"clean:all": "jlpm clean:lib && jlpm clean:labextension",
"install:labextension": "jlpm build",
"start:test": "python ./nbgrader/tests/ui-tests/utils/run_jupyter_lab.py",
"start:test:notebook": "python ./nbgrader/tests/ui-tests/utils/run_jupyter_notebook.py",
"start:test": "python ./nbgrader/tests/ui-tests/utils/run_jupyter_app.py",
"test": "jlpm playwright test",
"test:notebook": "jlpm playwright test --config=playwright.notebook.config.ts",
"test:notebook": "NBGRADER_TEST_IS_NOTEBOOK=1 jlpm playwright test --config=playwright.notebook.config.ts",
"watch": "run-p watch:src watch:labextension",
"watch:src": "tsc -w",
"watch:labextension": "jupyter labextension watch ."
Expand Down
5 changes: 2 additions & 3 deletions playwright.notebook.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ module.exports = {
appPath: '',
},
webServer: {
command: 'jlpm start:test:notebook',
command: 'jlpm start:test',
url: 'http://localhost:8888/tree',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
},

}
};
3 changes: 0 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ def _run_ts_test(args, notebook=False):
root_dir = mkdtemp(prefix="nbgrader-galata-")
os.environ["NBGRADER_TEST_DIR"] = root_dir

if notebook:
os.environ["NBGRADER_TEST_IS_NOTEBOOK"] = "1"

cmd = ['jlpm', f'test{":notebook" if notebook else ""}', '--retries=2'] + args
run(" ".join(cmd))

Expand Down

0 comments on commit 0230bbf

Please sign in to comment.