summaryrefslogtreecommitdiff
path: root/tests/context
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-03-21 10:52:34 +0000
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-03-21 10:52:34 +0000
commita392dd35a3831359e1ce2a82260bf15872325de1 (patch)
tree27f290fbbbf6f83761ea807138b9ea36f41322c6 /tests/context
parent245267b16375ca3de56b5f5209fe118f3b99ba46 (diff)
downloadbuildstream-a392dd35a3831359e1ce2a82260bf15872325de1.tar.gz
Fixed test cases for xdg dependency removal
Diffstat (limited to 'tests/context')
-rw-r--r--tests/context/context.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/context/context.py b/tests/context/context.py
index 76b05acb1..36eb22b4e 100644
--- a/tests/context/context.py
+++ b/tests/context/context.py
@@ -1,6 +1,5 @@
import os
import pytest
-from xdg import XDG_CACHE_HOME
from buildstream import Context
from buildstream import LoadError, LoadErrorReason
@@ -14,7 +13,13 @@ DATA_DIR = os.path.join(
# Simple fixture to create a Context object.
@pytest.fixture()
def context_fixture():
+ if os.environ.get('XDG_CACHE_HOME'):
+ cache_home = os.environ['XDG_CACHE_HOME']
+ else:
+ cache_home = os.path.expanduser('~/.cache')
+
return {
+ 'xdg-cache': cache_home,
'context': Context('x86_64')
}
@@ -33,13 +38,14 @@ def test_context_create(context_fixture):
#######################################
def test_context_load(context_fixture):
context = context_fixture['context']
+ cache_home = context_fixture['xdg-cache']
assert(isinstance(context, Context))
context.load()
- assert(context.sourcedir == os.path.join(XDG_CACHE_HOME, 'buildstream', 'sources'))
- assert(context.builddir == os.path.join(XDG_CACHE_HOME, 'buildstream', 'build'))
- assert(context.artifactdir == os.path.join(XDG_CACHE_HOME, 'buildstream', 'artifacts'))
- assert(context.logdir == os.path.join(XDG_CACHE_HOME, 'buildstream', 'logs'))
+ assert(context.sourcedir == os.path.join(cache_home, 'buildstream', 'sources'))
+ assert(context.builddir == os.path.join(cache_home, 'buildstream', 'build'))
+ assert(context.artifactdir == os.path.join(cache_home, 'buildstream', 'artifacts'))
+ assert(context.logdir == os.path.join(cache_home, 'buildstream', 'logs'))
# Test that values in a user specified config file
@@ -47,6 +53,7 @@ def test_context_load(context_fixture):
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_context_load_user_config(context_fixture, datafiles):
context = context_fixture['context']
+ cache_home = context_fixture['xdg-cache']
assert(isinstance(context, Context))
conf_file = os.path.join(datafiles.dirname,
@@ -55,9 +62,9 @@ def test_context_load_user_config(context_fixture, datafiles):
context.load(conf_file)
assert(context.sourcedir == os.path.expanduser('~/pony'))
- assert(context.builddir == os.path.join(XDG_CACHE_HOME, 'buildstream', 'build'))
- assert(context.artifactdir == os.path.join(XDG_CACHE_HOME, 'buildstream', 'artifacts'))
- assert(context.logdir == os.path.join(XDG_CACHE_HOME, 'buildstream', 'logs'))
+ assert(context.builddir == os.path.join(cache_home, 'buildstream', 'build'))
+ assert(context.artifactdir == os.path.join(cache_home, 'buildstream', 'artifacts'))
+ assert(context.logdir == os.path.join(cache_home, 'buildstream', 'logs'))
#######################################