Skip to content

Commit 5601172

Browse files
committed
Set up local test infrastructure
1 parent f702d28 commit 5601172

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
.DS_Store
2+
3+
*.pyc
4+
.cache

pytest.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
testpaths=tests
3+
norecursedirs=node_modules

tests/test_instantiate.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
import os
3+
import sys
4+
5+
import pytest
6+
7+
HERE = os.path.abspath(os.path.dirname(__file__))
8+
PROJECT_ROOT = os.path.dirname(HERE)
9+
10+
pytest_plugins = "pytester"
11+
12+
use_shell = os.name == 'nt'
13+
14+
15+
@pytest.fixture(scope='session')
16+
def example_instance(tmpdir_factory):
17+
from cookiecutter.main import cookiecutter
18+
import pip
19+
20+
tmpdir = tmpdir_factory.mktemp('example_instance')
21+
22+
with tmpdir.as_cwd():
23+
cookiecutter(PROJECT_ROOT, no_input=True, config_file=os.path.join(HERE, 'testconfig.yaml'))
24+
instance_path = tmpdir.join('jupyter-widget-testwidgets')
25+
with instance_path.as_cwd():
26+
print(str(instance_path))
27+
try:
28+
pip.main(['install', '-v', '-e', '.[test]'])
29+
yield instance_path
30+
finally:
31+
try:
32+
pip.main(['uninstall', 'ipywidgettestwidgets', '-y'])
33+
except Exception:
34+
pass
35+
36+
37+
def test_python_tests(example_instance, testdir):
38+
with example_instance.as_cwd():
39+
testdir.runpytest()
40+
41+
42+
def test_js_tests(example_instance):
43+
from subprocess import check_call
44+
45+
cmd = ['npm', 'test']
46+
with example_instance.as_cwd():
47+
check_call(cmd, stdout=sys.stdout, stderr=sys.stderr, shell=use_shell)

0 commit comments

Comments
 (0)