Skip to content

Commit a84863a

Browse files
committed
testing: fix layer tests when run with tox
This commit changes the way how the `versions.cfg` file, which contains the currently used CrateDB version for testing, is located at the project root.
1 parent 4bf85d3 commit a84863a

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/crate/testing/doctests/layer.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ tarball::
230230

231231
>>> import configparser
232232
>>> config = configparser.ConfigParser()
233-
>>> config.read(os.path.join(os.getcwd(), "..", "..", "versions.cfg"))
233+
>>> config.read(project_root("versions.cfg"))
234234
['.../versions.cfg']
235235

236236
>>> version = config["versions"]["crate_server"]

src/crate/testing/tests.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,27 @@
3030

3131

3232
def docs_path(*parts):
33-
return os.path.join(os.path.dirname(os.path.dirname(__file__)), *parts)
33+
return os.path.abspath(
34+
os.path.join(
35+
os.path.dirname(os.path.dirname(__file__)), *parts
36+
)
37+
)
38+
39+
40+
def project_root(*parts):
41+
return os.path.abspath(
42+
os.path.join(docs_path("..", ".."), *parts)
43+
)
3444

3545

3646
def crate_path(*parts):
37-
return os.path.abspath(docs_path('..', '..', 'parts', 'crate', *parts))
47+
return os.path.abspath(
48+
project_root("parts", "crate", *parts)
49+
)
3850

3951

4052
def setUp(test):
53+
test.globs['project_root'] = project_root
4154
test.globs['crate_path'] = crate_path
4255
test.globs['tempfile'] = tempfile
4356
test.globs['os'] = os

versions.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ createcoverage = 1.2
1616
docutils = 0.12
1717
hexagonit.recipe.download = 1.7
1818
py = 1.4.26
19-
tox = 1.8.1
19+
tox = 3.7.0
2020
twine = 1.8.1
2121
virtualenv = 15.1.0
2222
wheel = 0.24.0

0 commit comments

Comments
 (0)