Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa07f62914 | ||
|
|
764a587fed | ||
|
|
11c6a3ba43 |
3 changed files with 41 additions and 14 deletions
|
|
@ -1,9 +0,0 @@
|
||||||
[btest]
|
|
||||||
TestDirs = pysubnettree
|
|
||||||
TmpDir = %(testbase)s/.tmp
|
|
||||||
BaselineDir = %(testbase)s/Baseline
|
|
||||||
IgnoreDirs = .svn CVS .tmp
|
|
||||||
IgnoreFiles = *.tmp *.swp #* *.trace .DS_Store
|
|
||||||
|
|
||||||
[environment]
|
|
||||||
TMPDIR=%(testbase)s/.tmp
|
|
||||||
36
conftest.py
Normal file
36
conftest.py
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_collect_file(parent, file_path):
|
||||||
|
if file_path.suffix == ".test":
|
||||||
|
return BtestFile.from_parent(parent, path=file_path)
|
||||||
|
|
||||||
|
|
||||||
|
class BtestFile(pytest.File):
|
||||||
|
def collect(self):
|
||||||
|
yield BtestItem.from_parent(self, name=self.path.stem)
|
||||||
|
|
||||||
|
|
||||||
|
class BtestItem(pytest.Item):
|
||||||
|
def runtest(self):
|
||||||
|
result = subprocess.run(
|
||||||
|
[sys.executable, str(self.parent.path)],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise BtestFailure(result)
|
||||||
|
|
||||||
|
def repr_failure(self, excinfo):
|
||||||
|
exc = excinfo.value
|
||||||
|
return (exc.result.stdout + exc.result.stderr).strip()
|
||||||
|
|
||||||
|
def reportinfo(self):
|
||||||
|
return self.parent.path, None, f"btest: {self.name}"
|
||||||
|
|
||||||
|
|
||||||
|
class BtestFailure(Exception):
|
||||||
|
def __init__(self, result):
|
||||||
|
self.result = result
|
||||||
|
|
@ -7,15 +7,15 @@ Summary: Python Module for CIDR Lookups
|
||||||
License: BSD-3-Clause-LBNL and BSD-4-Clause
|
License: BSD-3-Clause-LBNL and BSD-4-Clause
|
||||||
URL: https://github.com/zeek/pysubnettree
|
URL: https://github.com/zeek/pysubnettree
|
||||||
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||||
# btest config file for RPM build environment
|
# pytest plugin to collect and run *.test files without btest
|
||||||
Source1: btest.cfg
|
Source1: conftest.py
|
||||||
|
|
||||||
Provides: pysubnettree = %{version}-%{release}
|
Provides: pysubnettree = %{version}-%{release}
|
||||||
Obsoletes: pysubnettree < 0.35-16
|
Obsoletes: pysubnettree < 0.35-16
|
||||||
|
|
||||||
BuildRequires: python3-devel
|
BuildRequires: python3-devel
|
||||||
BuildRequires: gcc-c++
|
BuildRequires: gcc-c++
|
||||||
BuildRequires: zeek-btest
|
BuildRequires: python3-pytest
|
||||||
|
|
||||||
|
|
||||||
%global _description %{expand:
|
%global _description %{expand:
|
||||||
|
|
@ -52,9 +52,9 @@ Summary: %{summary}
|
||||||
|
|
||||||
%check
|
%check
|
||||||
%pyproject_check_import
|
%pyproject_check_import
|
||||||
|
cp %{SOURCE1} testing/conftest.py
|
||||||
cd testing
|
cd testing
|
||||||
cp %{SOURCE1} btest.cfg
|
PYTHONPATH="%{buildroot}%{python3_sitearch}:$PWD/Scripts" pytest pysubnettree/
|
||||||
PYTHONPATH="%{buildroot}%{python3_sitearch}:$PWD/Scripts" btest -c btest.cfg -d
|
|
||||||
|
|
||||||
|
|
||||||
%files -n python3-pysubnettree -f %{pyproject_files}
|
%files -n python3-pysubnettree -f %{pyproject_files}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue