Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install testtools pbr ruff
python -m pip install testtools ruff
- name: Run ruff
run: |
python -m ruff check .
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
TAGS
tags
lib/testtools
MANIFEST
build
dist
*~
Expand All @@ -11,5 +10,5 @@ testscenarios.egg-info
*.pyc
__pycache__
*.egg
ChangeLog
AUTHORS
testscenarios/_version.py
tox.ini
10 changes: 0 additions & 10 deletions MANIFEST.in

This file was deleted.

7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PYTHONPATH:=$(shell pwd):${PYTHONPATH}
PYTHON ?= python
PYTHON ?= python3

all: check

Expand All @@ -16,7 +16,4 @@ TAGS: testscenarios/*.py testscenarios/tests/*.py
tags: testscenarios/*.py testscenarios/tests/*.py
ctags -R testscenarios/

release:
python setup.py sdist bdist_wheel upload -s

.PHONY: all check release
.PHONY: all check
65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "testscenarios"
description = "Testscenarios, a pyunit extension for dependency injection"
readme = "README.rst"
classifiers = [
"Development Status :: 6 - Mature",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
]
authors = [{name = "Testing-cabal", email = "[email protected]"}]
license = {text = "Apache-2.0 or BSD"}
requires-python = ">=3.10"
dynamic = ["version"]

[project.urls]
Homepage = "https://launchpad.net/testscenarios"
"Bug Tracker" = "https://bugs.launchpad.net/testscenarios"
"Source Code" = "https://github.com/testing-cabal/testscenarios"

[project.optional-dependencies]
"test" = ["testtools"]

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "testscenarios/_version.py"
tag-pattern = "^(testtools-)?(?P<version>[0-9]+(\\.[0-9]+)*(-[0-9]+)?)(\\.post(?P<post>[0-9]+))?$"
template = """\
# This file is automatically generated by hatch.
version = {version!r}
__version__ = {version_tuple!r}
"""

[tool.hatch.build.targets.sdist]
include = [
"testscenarios*",
"APACHE-2.0",
"AUTHORS",
"BSD",
"ChangeLog",
"COPYING",
"GOALS",
"HACKING",
"Makefile",
"NEWS",
"README.rst",
"tox.ini",
"doc/*.py",
]
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pbr >= 0.11
testtools
28 changes: 0 additions & 28 deletions setup.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

68 changes: 51 additions & 17 deletions testscenarios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,6 @@
methods for details.
"""

# same format as sys.version_info: "A tuple containing the five components of
# the version number: major, minor, micro, releaselevel, and serial. All
# values except releaselevel are integers; the release level is 'alpha',
# 'beta', 'candidate', or 'final'. The version_info value corresponding to the
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
# releaselevel of 'dev' for unreleased under-development code.
#
# If the releaselevel is 'alpha' then the major/minor/micro components are not
# established at this point, and setup.py will use a version of next-$(revno).
# If the releaselevel is 'final', then the tarball will be major.minor.micro.
# Otherwise it is major.minor.micro~$(revno).
from pbr.version import VersionInfo

_version = VersionInfo("testscenarios")
__version__ = _version.semantic_version().version_tuple()
version = _version.release_string()

__all__ = [
"TestWithScenarios",
"WithScenarios",
Expand All @@ -53,6 +36,7 @@
"load_tests_apply_scenarios",
"multiply_scenarios",
"per_module_scenarios",
"__version__",
]


Expand All @@ -76,3 +60,53 @@ def test_suite():
def load_tests(standard_tests, module, loader):
standard_tests.addTests(loader.loadTestsFromNames(["testscenarios.tests"]))
return standard_tests


def __get_git_version():
import os
import subprocess

cwd = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)

try:
out = subprocess.check_output(
["git", "describe"], stderr=subprocess.STDOUT, cwd=cwd
)
except (OSError, subprocess.CalledProcessError):
return None

try:
version = out.strip().decode("utf-8")
except UnicodeDecodeError:
return None

if "-" in version: # after tag
# convert version-N-githash to version.postN+githash
return version.replace("-", ".post", 1).replace("-g", "+git", 1)
else:
return version


# same format as sys.version_info: "A tuple containing the five components of
# the version number: major, minor, micro, releaselevel, and serial. All
# values except releaselevel are integers; the release level is 'alpha',
# 'beta', 'candidate', or 'final'. The version_info value corresponding to the
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
# releaselevel of 'dev' for unreleased under-development code.
#
# If the releaselevel is 'alpha' then the major/minor/micro components are not
# established at this point, and setup.py will use a version of next-$(revno).
# If the releaselevel is 'final', then the tarball will be major.minor.micro.
# Otherwise it is major.minor.micro~$(revno).

try:
from ._version import __version__, version
except ModuleNotFoundError:
# package is not installed
if version := __get_git_version():
# we're in a git repo
__version__ = tuple([int(v) if v.isdigit() else v for v in version.split(".")])
else:
# we're working with a tarball or similar
version = "0.0.0"
__version__ = (0, 0, 0)
4 changes: 2 additions & 2 deletions testscenarios/tests/test_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_load_tests_apply_scenarios(self):
unittest.TestLoader(), [self.SampleTest("test_nothing")], None
)
result_tests = list(testtools.iterate_tests(suite))
self.assertEquals(2, len(result_tests), result_tests)
self.assertEqual(2, len(result_tests), result_tests)

def test_load_tests_apply_scenarios_old_style(self):
"""Call load_tests in the way used by bzr."""
Expand All @@ -214,7 +214,7 @@ def test_load_tests_apply_scenarios_old_style(self):
unittest.TestLoader(),
)
result_tests = list(testtools.iterate_tests(suite))
self.assertEquals(2, len(result_tests), result_tests)
self.assertEqual(2, len(result_tests), result_tests)


class TestMultiplyScenarios(testtools.TestCase):
Expand Down