diff --git a/test/pmb_test/__init__.py b/test/pmb_test/__init__.py
new file mode 100644
index 00000000..b0370f42
--- /dev/null
+++ b/test/pmb_test/__init__.py
@@ -0,0 +1,25 @@
+"""
+Copyright 2020 Oliver Smith
+
+This file is part of pmbootstrap.
+
+pmbootstrap is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+pmbootstrap is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with pmbootstrap. If not, see .
+"""
+
+import os
+import sys
+
+# Add topdir to import path
+topdir = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/../.."))
+sys.path.insert(0, topdir)
diff --git a/test/pmb_test/const.py b/test/pmb_test/const.py
new file mode 100644
index 00000000..0dff26e7
--- /dev/null
+++ b/test/pmb_test/const.py
@@ -0,0 +1,23 @@
+"""
+Copyright 2020 Oliver Smith
+
+This file is part of pmbootstrap.
+
+pmbootstrap is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+pmbootstrap is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with pmbootstrap. If not, see .
+"""
+
+import pmb.config
+
+
+testdata = pmb.config.pmb_src + "/test/testdata"
diff --git a/test/test_apk_static.py b/test/test_apk_static.py
index 329cceea..824d0bdd 100644
--- a/test/test_apk_static.py
+++ b/test/test_apk_static.py
@@ -22,9 +22,7 @@ import tarfile
import glob
import pytest
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test # noqa
import pmb.chroot.apk_static
import pmb.config
import pmb.parse.apkindex
diff --git a/test/test_aportgen.py b/test/test_aportgen.py
index ad04cfe5..af3ec7f2 100644
--- a/test/test_aportgen.py
+++ b/test/test_aportgen.py
@@ -22,10 +22,8 @@ import pytest
import shutil
import filecmp
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
-
+import pmb_test
+import pmb_test.const
import pmb.aportgen
import pmb.aportgen.core
import pmb.config
@@ -50,7 +48,7 @@ def test_aportgen_compare_output(args, tmpdir, monkeypatch):
shutil.copytree(args.aports + "/.git", tmpdir + "/.git")
args.aports = tmpdir
os.mkdir(tmpdir + "/cross")
- testdata = pmb_src + "/test/testdata/aportgen"
+ testdata = pmb_test.const.testdata + "/aportgen"
# Override get_upstream_aport() to point to testdata
def func(args, upstream_path):
@@ -73,7 +71,7 @@ def test_aportgen_fork_alpine_compare_output(args, tmpdir, monkeypatch):
shutil.copytree(args.aports + "/.git", tmpdir + "/.git")
args.aports = tmpdir
os.mkdir(tmpdir + "/temp")
- testdata = pmb_src + "/test/testdata/aportgen"
+ testdata = pmb_test.const.testdata + "/aportgen"
args.fork_alpine = True
# Override get_upstream_aport() to point to testdata
diff --git a/test/test_aportgen_device_wizard.py b/test/test_aportgen_device_wizard.py
index 8e19f8bf..133ce33d 100644
--- a/test/test_aportgen_device_wizard.py
+++ b/test/test_aportgen_device_wizard.py
@@ -17,14 +17,11 @@ You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
import logging
-import os
import pytest
import sys
import shutil
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.aportgen
import pmb.config
import pmb.helpers.logging
diff --git a/test/test_bootimg.py b/test/test_bootimg.py
index c98678b0..615b2bee 100644
--- a/test/test_bootimg.py
+++ b/test/test_bootimg.py
@@ -16,13 +16,11 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import sys
import pytest
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test
+import pmb_test.const
import pmb.chroot.apk_static
import pmb.parse.apkindex
import pmb.helpers.logging
@@ -47,7 +45,7 @@ def test_bootimg_invalid_path(args):
def test_bootimg_kernel(args):
- path = pmb_src + "/test/testdata/bootimg/kernel-boot.img"
+ path = pmb_test.const.testdata + "/bootimg/kernel-boot.img"
with pytest.raises(RuntimeError) as e:
pmb.parse.bootimg(args, path)
assert "heimdall-isorec" in str(e.value)
@@ -60,7 +58,7 @@ def test_bootimg_invalid_file(args):
def test_bootimg_normal(args):
- path = pmb_src + "/test/testdata/bootimg/normal-boot.img"
+ path = pmb_test.const.testdata + "/bootimg/normal-boot.img"
output = {"base": "0x80000000",
"kernel_offset": "0x00008000",
"ramdisk_offset": "0x04000000",
@@ -74,7 +72,7 @@ def test_bootimg_normal(args):
def test_bootimg_qcdt(args):
- path = pmb_src + "/test/testdata/bootimg/qcdt-boot.img"
+ path = pmb_test.const.testdata + "/bootimg/qcdt-boot.img"
output = {"base": "0x80000000",
"kernel_offset": "0x00008000",
"ramdisk_offset": "0x04000000",
@@ -88,7 +86,7 @@ def test_bootimg_qcdt(args):
def test_bootimg_dtb_second(args):
- path = pmb_src + "/test/testdata/bootimg/dtb-second-boot.img"
+ path = pmb_test.const.testdata + "/bootimg/dtb-second-boot.img"
output = {"base": "0x00000000",
"kernel_offset": "0x00008000",
"ramdisk_offset": "0x02000000",
diff --git a/test/test_build_is_necessary.py b/test/test_build_is_necessary.py
index cf41bbad..a0cf4ae9 100644
--- a/test/test_build_is_necessary.py
+++ b/test/test_build_is_necessary.py
@@ -20,9 +20,7 @@ import os
import sys
import pytest
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.helpers.logging
import pmb.helpers.pmaports
diff --git a/test/test_build_package.py b/test/test_build_package.py
index 551a61aa..fb4da0ce 100644
--- a/test/test_build_package.py
+++ b/test/test_build_package.py
@@ -28,9 +28,7 @@ import pytest
import shutil
import sys
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.build
import pmb.build._package
import pmb.config
diff --git a/test/test_chroot_interactive_shell.py b/test/test_chroot_interactive_shell.py
index f51e14f7..d653ca21 100644
--- a/test/test_chroot_interactive_shell.py
+++ b/test/test_chroot_interactive_shell.py
@@ -18,14 +18,15 @@ along with pmbootstrap. If not, see .
"""
import subprocess
import os
+import pmb_test # noqa
+import pmb.config
def test_chroot_interactive_shell():
"""
Open a shell with 'pmbootstrap chroot' and pass 'echo hello_world\n' as stdin.
"""
- pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
- os.chdir(pmb_src)
+ os.chdir(pmb.config.pmb_src)
ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot", "sh"],
timeout=300, input="echo hello_world\n",
universal_newlines=True,
@@ -37,8 +38,7 @@ def test_chroot_interactive_shell_user():
"""
Open a shell with 'pmbootstrap chroot' as user, and test the resulting ID.
"""
- pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
- os.chdir(pmb_src)
+ os.chdir(pmb.config.pmb_src)
ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot",
"--user", "sh"], timeout=300, input="id -un",
universal_newlines=True,
@@ -51,8 +51,7 @@ def test_chroot_arguments():
Open a shell with 'pmbootstrap chroot' for every architecture, pass 'uname -m\n'
as stdin and check the output
"""
- pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
- os.chdir(pmb_src)
+ os.chdir(pmb.config.pmb_src)
for arch in ["armhf", "aarch64", "x86_64"]:
ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot", "-b", arch,
diff --git a/test/test_config_init.py b/test/test_config_init.py
index 7e82bd1e..558f88ec 100644
--- a/test/test_config_init.py
+++ b/test/test_config_init.py
@@ -16,13 +16,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import pytest
-import sys
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.config.init
diff --git a/test/test_config_user.py b/test/test_config_user.py
index 77e04aa9..935d9708 100644
--- a/test/test_config_user.py
+++ b/test/test_config_user.py
@@ -16,13 +16,10 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import sys
import pytest
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.aportgen
import pmb.config
import pmb.helpers.frontend
diff --git a/test/test_cross_compile_distcc.py b/test/test_cross_compile_distcc.py
index 9189ab00..5dec67dd 100644
--- a/test/test_cross_compile_distcc.py
+++ b/test/test_cross_compile_distcc.py
@@ -21,9 +21,7 @@ import os
import pytest
import sys
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.build
import pmb.chroot.distccd
import pmb.helpers.logging
diff --git a/test/test_crossdirect.py b/test/test_crossdirect.py
index 86c31a6a..2a7e92fa 100644
--- a/test/test_crossdirect.py
+++ b/test/test_crossdirect.py
@@ -17,13 +17,10 @@ You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import pytest
import sys
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test # noqa
import pmb.chroot.apk_static
import pmb.parse.apkindex
import pmb.helpers.logging
@@ -45,7 +42,8 @@ def args(request):
def pmbootstrap_run(args, parameters, check=True):
"""Execute pmbootstrap.py with a test pmbootstrap.conf."""
return pmb.helpers.run.user(args, ["./pmbootstrap.py"] + parameters,
- working_dir=pmb_src, check=check)
+ working_dir=pmb.config.pmb_src,
+ check=check)
def test_crossdirect_rust(args):
diff --git a/test/test_envkernel.py b/test/test_envkernel.py
index 94f67ee6..3ba89ca4 100644
--- a/test/test_envkernel.py
+++ b/test/test_envkernel.py
@@ -16,14 +16,11 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import sys
import pytest
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
-
+import pmb_test
+import pmb_test.const
import pmb.aportgen
import pmb.aportgen.core
import pmb.build
@@ -54,8 +51,7 @@ def test_package_kernel_args(args):
def test_find_kbuild_output_dir(args):
# Test parsing an APKBUILD
pkgname = "linux-envkernel-test"
- testdata = pmb_src + "/test/testdata"
- path = testdata + "/apkbuild/APKBUILD." + pkgname
+ path = pmb_test.const.testdata + "/apkbuild/APKBUILD." + pkgname
function_body = pmb.parse.function_body(path, "package")
kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(args,
function_body)
diff --git a/test/test_file.py b/test/test_file.py
index 22981a1e..2785e13f 100644
--- a/test/test_file.py
+++ b/test/test_file.py
@@ -21,9 +21,7 @@ import sys
import time
import pytest
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.helpers.git
import pmb.helpers.logging
import pmb.parse.version
diff --git a/test/test_folder_size.py b/test/test_folder_size.py
index e06f4991..ba6d02ec 100644
--- a/test/test_folder_size.py
+++ b/test/test_folder_size.py
@@ -16,13 +16,10 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import sys
import pytest
-# Import from parent directory
-sys.path.insert(0, os.path.abspath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.helpers.logging
import pmb.helpers.other
import pmb.helpers.run
diff --git a/test/test_frontend.py b/test/test_frontend.py
index e5c9c1e3..27fbd035 100644
--- a/test/test_frontend.py
+++ b/test/test_frontend.py
@@ -16,13 +16,10 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import sys
import pytest
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.config
import pmb.parse
import pmb.helpers.frontend
diff --git a/test/test_helpers_git.py b/test/test_helpers_git.py
index d4c95d6d..a8049339 100644
--- a/test/test_helpers_git.py
+++ b/test/test_helpers_git.py
@@ -22,9 +22,7 @@ import sys
import pytest
import shutil
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.helpers.git
import pmb.helpers.logging
import pmb.helpers.run
diff --git a/test/test_helpers_package.py b/test/test_helpers_package.py
index 65dbc5bf..157ca5c2 100644
--- a/test/test_helpers_package.py
+++ b/test/test_helpers_package.py
@@ -16,13 +16,10 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import sys
import pytest
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.helpers.logging
import pmb.helpers.package
diff --git a/test/test_helpers_pmaports.py b/test/test_helpers_pmaports.py
index cf2fc216..848a777a 100644
--- a/test/test_helpers_pmaports.py
+++ b/test/test_helpers_pmaports.py
@@ -21,9 +21,7 @@ import os
import pytest
import sys
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.build.other
diff --git a/test/test_helpers_repo_missing.py b/test/test_helpers_repo_missing.py
index e3562040..8215b584 100644
--- a/test/test_helpers_repo_missing.py
+++ b/test/test_helpers_repo_missing.py
@@ -17,13 +17,10 @@ You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import pytest
import sys
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.build.other
diff --git a/test/test_install.py b/test/test_install.py
index 0ef7e9de..37cb0fc1 100644
--- a/test/test_install.py
+++ b/test/test_install.py
@@ -16,13 +16,11 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import pytest
import sys
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test
+import pmb_test.const
import pmb.aportgen.device
import pmb.config
import pmb.config.init
@@ -42,7 +40,7 @@ def args(tmpdir, request):
def test_get_nonfree_packages(args):
- args.aports = pmb_src + "/test/testdata/init_questions_device/aports"
+ args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
func = pmb.install._install.get_nonfree_packages
# Device without any non-free subpackages
diff --git a/test/test_keys.py b/test/test_keys.py
index d4c28073..ccaff3c1 100644
--- a/test/test_keys.py
+++ b/test/test_keys.py
@@ -22,9 +22,7 @@ import pytest
import glob
import filecmp
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.parse.apkindex
import pmb.helpers.logging
import pmb.config
diff --git a/test/test_mount.py b/test/test_mount.py
index 4b1f4d42..df7cf85d 100644
--- a/test/test_mount.py
+++ b/test/test_mount.py
@@ -16,12 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
-import sys
-
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.helpers.mount
diff --git a/test/test_newapkbuild.py b/test/test_newapkbuild.py
index 4beedf9b..ac650650 100644
--- a/test/test_newapkbuild.py
+++ b/test/test_newapkbuild.py
@@ -21,9 +21,7 @@ import os
import pytest
import sys
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.build.newapkbuild
import pmb.config
import pmb.config.init
diff --git a/test/test_parse_apkbuild.py b/test/test_parse_apkbuild.py
index 76c92c5d..6376a689 100644
--- a/test/test_parse_apkbuild.py
+++ b/test/test_parse_apkbuild.py
@@ -17,13 +17,11 @@ You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import pytest
import sys
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test
+import pmb_test.const
import pmb.parse._apkbuild
@@ -39,8 +37,7 @@ def args(tmpdir, request):
def test_subpackages(args):
- testdata = pmb_src + "/test/testdata"
-
+ testdata = pmb_test.const.testdata
path = testdata + "/apkbuild/APKBUILD.subpackages"
apkbuild = pmb.parse.apkbuild(args, path, check_pkgname=False)
@@ -72,7 +69,7 @@ def test_subpackages(args):
def test_kernels(args):
# Kernel hardcoded in depends
- args.aports = pmb_src + "/test/testdata/init_questions_device/aports"
+ args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
func = pmb.parse._apkbuild.kernels
device = "lg-mako"
assert func(args, device) is None
@@ -92,7 +89,7 @@ def test_kernels(args):
def test_depends_in_depends(args):
- path = pmb_src + "/test/testdata/apkbuild/APKBUILD.depends-in-depends"
+ path = pmb_test.const.testdata + "/apkbuild/APKBUILD.depends-in-depends"
apkbuild = pmb.parse.apkbuild(args, path, check_pkgname=False)
assert apkbuild["depends"] == ["first", "second", "third"]
@@ -143,7 +140,7 @@ def test_parse_attributes():
def test_variable_replacements(args):
- path = pmb_src + "/test/testdata/apkbuild/APKBUILD.variable-replacements"
+ path = pmb_test.const.testdata + "/apkbuild/APKBUILD.variable-replacements"
apkbuild = pmb.parse.apkbuild(args, path, check_pkgname=False)
assert apkbuild["pkgdesc"] == "this should not affect variable replacement"
assert apkbuild["url"] == "replacements variable string-replacements"
diff --git a/test/test_parse_apkindex.py b/test/test_parse_apkindex.py
index 7ca912c4..560ce63d 100644
--- a/test/test_parse_apkindex.py
+++ b/test/test_parse_apkindex.py
@@ -26,9 +26,7 @@ import os
import pytest
import sys
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.parse.apkindex
import pmb.helpers.logging
import pmb.helpers.repo
diff --git a/test/test_parse_depends.py b/test/test_parse_depends.py
index 3739c814..c9fc088b 100644
--- a/test/test_parse_depends.py
+++ b/test/test_parse_depends.py
@@ -22,13 +22,10 @@ This file tests all functions from pmb.parse.depends.
"""
import collections
-import os
import pytest
import sys
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.config
import pmb.config.init
import pmb.helpers.logging
diff --git a/test/test_pkgrel_bump.py b/test/test_pkgrel_bump.py
index 0d172cc5..303644a1 100644
--- a/test/test_pkgrel_bump.py
+++ b/test/test_pkgrel_bump.py
@@ -27,9 +27,7 @@ import pytest
import shutil
import sys
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test # noqa
import pmb.helpers.pkgrel_bump
import pmb.helpers.logging
@@ -67,7 +65,7 @@ def pmbootstrap(args, tmpdir, parameters, zero_exit=True):
pmb.helpers.run.user(args, ["./pmbootstrap.py", "--work=" + tmpdir,
"--mirror-pmOS=", "--aports=" + aports,
"--config=" + config] + parameters,
- working_dir=pmb_src)
+ working_dir=pmb.config.pmb_src)
# Verify that it exits as desired
except Exception as exc:
@@ -88,7 +86,7 @@ def setup_work(args, tmpdir):
# Clean the chroots, and initialize the build chroot in the native chroot.
# We do this before creating the fake work folder, because then all packages
# are still present.
- os.chdir(pmb_src)
+ os.chdir(pmb.config.pmb_src)
pmb.helpers.run.user(args, ["./pmbootstrap.py", "-y", "zap"])
pmb.helpers.run.user(args, ["./pmbootstrap.py", "build_init"])
pmb.helpers.run.user(args, ["./pmbootstrap.py", "shutdown"])
diff --git a/test/test_qemu_running_processes.py b/test/test_qemu_running_processes.py
index a6ca1286..ce3f6b65 100644
--- a/test/test_qemu_running_processes.py
+++ b/test/test_qemu_running_processes.py
@@ -32,9 +32,7 @@ import shutil
import shlex
import time
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test # noqa
import pmb.chroot.apk_static
import pmb.parse.apkindex
import pmb.helpers.logging
@@ -63,7 +61,7 @@ def ssh_create_askpass_script(args):
def pmbootstrap_run(args, config, parameters, output="log"):
"""Execute pmbootstrap.py with a test pmbootstrap.conf."""
return pmb.helpers.run.user(args, ["./pmbootstrap.py", "-c", config] +
- parameters, working_dir=pmb_src,
+ parameters, working_dir=pmb.config.pmb_src,
output=output)
@@ -80,7 +78,7 @@ def pmbootstrap_yes(args, config, parameters):
for parameter in parameters:
command += " " + shlex.quote(parameter)
return pmb.helpers.run.user(args, ["/bin/sh", "-c", command],
- working_dir=pmb_src)
+ working_dir=pmb.config.pmb_src)
class QEMU(object):
diff --git a/test/test_questions.py b/test/test_questions.py
index b11e13b1..01b407b0 100644
--- a/test/test_questions.py
+++ b/test/test_questions.py
@@ -21,9 +21,8 @@ import os
import pytest
import sys
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test
+import pmb_test.const
import pmb.aportgen.device
import pmb.config
import pmb.config.init
@@ -104,7 +103,7 @@ def test_questions_bootimg(args, monkeypatch):
fake_answers(monkeypatch, ["invalid_path", ""])
assert func(args) is None
- bootimg_path = pmb_src + "/test/testdata/bootimg/normal-boot.img"
+ bootimg_path = pmb_test.const.testdata + "/bootimg/normal-boot.img"
fake_answers(monkeypatch, [bootimg_path])
output = {"base": "0x80000000",
"kernel_offset": "0x00008000",
@@ -120,7 +119,7 @@ def test_questions_bootimg(args, monkeypatch):
def test_questions_device(args, monkeypatch):
# Prepare args
- args.aports = pmb_src + "/test/testdata/init_questions_device/aports"
+ args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
args.device = "lg-mako"
args.nonfree_firmware = True
args.nonfree_userland = False
@@ -157,7 +156,7 @@ def test_questions_device(args, monkeypatch):
def test_questions_device_kernel(args, monkeypatch):
# Prepare args
- args.aports = pmb_src + "/test/testdata/init_questions_device/aports"
+ args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
args.kernel = "downstream"
# Kernel hardcoded in depends
@@ -177,7 +176,7 @@ def test_questions_device_kernel(args, monkeypatch):
def test_questions_device_nonfree(args, monkeypatch):
# Prepare args
- args.aports = pmb_src + "/test/testdata/init_questions_device/aports"
+ args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
args.nonfree_firmware = False
args.nonfree_userland = False
diff --git a/test/test_repo.py b/test/test_repo.py
index cab78b98..fd61880e 100644
--- a/test/test_repo.py
+++ b/test/test_repo.py
@@ -16,13 +16,10 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import pytest
import sys
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test # noqa
import pmb.helpers.repo
diff --git a/test/test_run_core.py b/test/test_run_core.py
index 78878726..6fa2df9e 100644
--- a/test/test_run_core.py
+++ b/test/test_run_core.py
@@ -21,14 +21,11 @@ along with pmbootstrap. If not, see .
This file tests functions from pmb.helpers.run_core
"""
-import os
import sys
import subprocess
import pytest
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test # noqa
import pmb.helpers.run_core
diff --git a/test/test_shell_escape.py b/test/test_shell_escape.py
index c63d57d6..e5b1327f 100644
--- a/test/test_shell_escape.py
+++ b/test/test_shell_escape.py
@@ -16,13 +16,10 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import sys
import pytest
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test # noqa
import pmb.chroot.root
import pmb.chroot.user
import pmb.helpers.run
diff --git a/test/test_version.py b/test/test_version.py
index 69ca9c6a..763e3383 100644
--- a/test/test_version.py
+++ b/test/test_version.py
@@ -16,13 +16,11 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
import sys
import pytest
-# Import from parent directory
-pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/.."))
-sys.path.insert(0, pmb_src)
+import pmb_test
+import pmb_test.const
import pmb.helpers.git
import pmb.helpers.logging
import pmb.parse.version
@@ -44,7 +42,7 @@ def test_version(args):
keep_going = False
# Iterate over the version tests from apk-tools
- path = pmb_src + "/test/testdata/version/version.data"
+ path = pmb_test.const.testdata + "/version/version.data"
mapping = {-1: "<", 0: "=", 1: ">"}
count = 0
errors = []
diff --git a/test/test_version_validate.py b/test/test_version_validate.py
index 0d6467b1..eedf81b5 100644
--- a/test/test_version_validate.py
+++ b/test/test_version_validate.py
@@ -16,12 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with pmbootstrap. If not, see .
"""
-import os
-import sys
-
-# Import from parent directory
-sys.path.insert(0, os.path.realpath(
- os.path.join(os.path.dirname(__file__) + "/..")))
+import pmb_test # noqa
import pmb.parse.version