Skip to content

Commit 216d7d7

Browse files
authored
Merge pull request #1540 from jenshnielsen/fix_tests_in_shell
Run tests on installed code
2 parents 42c5fe6 + 3b67920 commit 216d7d7

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

.travis.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,17 @@ script:
6767
- |
6868
cd docs
6969
make SPHINXOPTS="-W -v" htmlapi
70-
- cd ..
70+
# rerun the tests from within a python session to ensure that all fixtures
71+
# are bundled correctly. To save time we only do this from python 3.6
72+
- |
73+
cd $HOME
74+
if [[ $TRAVIS_PYTHON_VERSION == "3.6" ]]; then
75+
python -c "import sys; import qcodes; ec = qcodes.test(); sys.exit(ec)"
76+
fi
7177
7278
after_success:
7379
# upload code coverage
80+
- cd $TRAVIS_BUILD_DIR
7481
- python-codacy-coverage -r qcodes/coverage.xml
7582
- codecov
7683
# upload the docs

qcodes/tests/dataset/test_guids.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def protected_config():
2929
cfg.save_to_home()
3030

3131

32-
@settings(max_examples=50)
32+
@settings(max_examples=50, deadline=1000)
3333
@given(loc=hst.integers(0, 255), stat=hst.integers(0, 65535),
3434
smpl=hst.integers(0, 4294967295))
3535
def test_generate_guid(loc, stat, smpl):

qcodes/tests/test_config.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import jsonschema
33
import os
44
import json
5+
import unittest
6+
from pathlib import Path
57

68
from functools import partial
79
from contextlib import contextmanager
@@ -24,13 +26,13 @@
2426
"user": {"foo": "1"},
2527
"c": 3, "bar": True, "z": 4}
2628

27-
# expected config after updade by user
29+
# expected config after update by user
2830
UPDATED_CONFIG = {"a": 1, "b": 2, "h": 2,
2931
"user": {"foo": "bar"},
3032
"c": 3, "bar": True, "z": 4}
3133

3234
# the schema does not cover extra fields, so users can pass
33-
# wathever they want
35+
# whatever they want
3436
SCHEMA = {
3537
"$schema": "http://json-schema.org/draft-04/schema#",
3638
"type": "object",
@@ -60,7 +62,7 @@
6062
]
6163
}
6264

63-
# schema updaed by adding custom fileds by the
65+
# schema updated by adding custom fields by the
6466
UPDATED_SCHEMA = {
6567
"$schema": "http://json-schema.org/draft-04/schema#",
6668
"type": "object",
@@ -125,7 +127,7 @@
125127
Config.schema_default_file_name: SCHEMA,
126128
}
127129

128-
# in this case the home config is messging up a type
130+
# in this case the home config is messing up a type
129131
BAD_CONFIG_MAP = {Config.default_file_name: {"z": 1, "a": 1, "b": 0},
130132
ENV_KEY: {"z": 3, "h": 2, "user": {"foo": 1}},
131133
Config.home_file_name: {"z": 3, "b": "2", "user": "foo"},
@@ -138,10 +140,10 @@
138140

139141

140142
@contextmanager
141-
def default_config(user_config: Optional[str]=None):
143+
def default_config(user_config: Optional[str] = None):
142144
"""
143145
Context manager to temporarily establish default config settings.
144-
This is achieved by overwritting the config paths of the user-,
146+
This is achieved by overwriting the config paths of the user-,
145147
environment-, and current directory-config files with the path of the
146148
config file in the qcodes repository.
147149
Additionally the current config object `qcodes.config` gets copied and
@@ -230,6 +232,9 @@ def test_missing_config_file(self):
230232
@patch.object(Config, 'env_file_name', new_callable=PropertyMock)
231233
@patch.object(Config, 'load_config')
232234
@patch('os.path.isfile')
235+
@unittest.skipIf(Path.cwd() == Path.home(),
236+
'This test requires that working dir is different from'
237+
'homedir.')
233238
def test_default_config_files(self, isfile, load_config, env, schema):
234239
# don't try to load custom schemas
235240
self.conf.schema_cwd_file_name = None
@@ -247,6 +252,9 @@ def test_default_config_files(self, isfile, load_config, env, schema):
247252
@patch.object(Config, 'env_file_name', new_callable=PropertyMock)
248253
@patch.object(Config, 'load_config')
249254
@patch('os.path.isfile')
255+
@unittest.skipIf(Path.cwd() == Path.home(),
256+
'This test requires that working dir is different from'
257+
'homedir.')
250258
def test_bad_config_files(self, isfile, load_config, env, schema):
251259
# don't try to load custom schemas
252260
self.conf.schema_cwd_file_name = None
@@ -265,6 +273,9 @@ def test_bad_config_files(self, isfile, load_config, env, schema):
265273
@patch.object(Config, 'load_config')
266274
@patch('os.path.isfile')
267275
@patch("builtins.open", mock_open(read_data=USER_SCHEMA))
276+
@unittest.skipIf(Path.cwd() == Path.home(),
277+
'This test requires that working dir is different from'
278+
'homedir.')
268279
def test_user_schema(self, isfile, load_config, env, schema):
269280
schema.return_value = copy.deepcopy(SCHEMA)
270281
env.return_value = ENV_KEY

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def readme():
5959
package_data={'qcodes': ['monitor/dist/*', 'monitor/dist/js/*',
6060
'monitor/dist/css/*', 'config/*.json',
6161
'instrument/sims/*.yaml',
62-
'tests/dataset/fixtures/2018-01-17/*/*']},
62+
'tests/dataset/fixtures/2018-01-17/*/*',
63+
'tests/drivers/auxiliary_files/*']},
6364
install_requires=[
6465
'numpy>=1.10',
6566
'pyvisa>=1.9.1',

0 commit comments

Comments
 (0)