test/pmb_test: prepare for common test code (!1876)

Replace the "Add topdir to import path" boilerplate lines in each test
file with a simple "import pmb_test". Use the "# noqa" comment if
"pmb_test" is not used further in the test file, so flake8 does not
complain about an unused module.

Make the path to the testdata available as pmb_test.const.testdata, and
use pmb.config.pmb_src to access the topdir in all tests.

This is in preparation for new "pmbootstrap status" related tests, which
will have shared test code in test/pmb_test/. Also, this makes the
pmbootstrap codebase more consistent with the bpo codebase, which has a
similar "import bpo_test" mechanism.
This commit is contained in:
Oliver Smith 2020-02-20 20:14:38 +01:00 committed by Alexey Min
parent 4a08b5e066
commit e605a0af32
No known key found for this signature in database
GPG key ID: 0B19D2A65870B448
36 changed files with 116 additions and 155 deletions

View file

@ -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 <http://www.gnu.org/licenses/>.
"""
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)