python3Packages.bork: add test using testers.runCommand

This will serve as a “real-world” example, running tests requiring network.
This commit is contained in:
nicoo 2024-08-08 14:28:17 +00:00
parent d0a96c6eda
commit 244229a8b6
3 changed files with 33 additions and 0 deletions

View File

@ -19,6 +19,8 @@ lib.recurseIntoAttrs {
shellcheck = pkgs.callPackage ../shellcheck/tests.nix { };
runCommand = lib.recurseIntoAttrs {
bork = pkgs.python3Packages.bork.tests.pytest-network;
dns-resolution = testers.runCommand {
name = "runCommand-dns-resolution-test";
nativeBuildInputs = [ pkgs.ldns ];

View File

@ -1,6 +1,7 @@
{
lib,
buildPythonPackage,
callPackage,
fetchFromGitHub,
pytestCheckHook,
pythonOlder,
@ -61,6 +62,8 @@ buildPythonPackage rec {
"test_repo"
];
passthru.tests = callPackage ./tests.nix { };
meta = with lib; {
description = "Python build and release management tool";
mainProgram = "bork";

View File

@ -0,0 +1,28 @@
{
testers,
bork,
cacert,
git,
pytest,
}:
{
# a.k.a. `tests.testers.runCommand.bork`
pytest-network = testers.runCommand {
name = "bork-pytest-network";
nativeBuildInputs = [
bork
cacert
git
pytest
];
script = ''
# Copy the source tree over, and make it writeable
cp -r ${bork.src} bork/
find -type d -exec chmod 0755 '{}' '+'
pytest -v -m network bork/
touch $out
'';
};
}