punit 1.8.1__tar.gz → 1.9.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {punit-1.8.1/src/pUnit.egg-info → punit-1.9.2}/PKG-INFO +2 -1
  2. {punit-1.8.1 → punit-1.9.2}/pyproject.toml +2 -1
  3. {punit-1.8.1 → punit-1.9.2/src/pUnit.egg-info}/PKG-INFO +2 -1
  4. {punit-1.8.1 → punit-1.9.2}/src/pUnit.egg-info/requires.txt +1 -0
  5. {punit-1.8.1 → punit-1.9.2}/src/punit/__init__.py +2 -2
  6. {punit-1.8.1 → punit-1.9.2}/src/punit/__main__.py +23 -7
  7. {punit-1.8.1 → punit-1.9.2}/src/punit/cli.py +22 -2
  8. {punit-1.8.1 → punit-1.9.2}/src/punit/runner.py +10 -4
  9. {punit-1.8.1 → punit-1.9.2}/LICENSE +0 -0
  10. {punit-1.8.1 → punit-1.9.2}/README.md +0 -0
  11. {punit-1.8.1 → punit-1.9.2}/setup.cfg +0 -0
  12. {punit-1.8.1 → punit-1.9.2}/src/pUnit.egg-info/SOURCES.txt +0 -0
  13. {punit-1.8.1 → punit-1.9.2}/src/pUnit.egg-info/dependency_links.txt +0 -0
  14. {punit-1.8.1 → punit-1.9.2}/src/pUnit.egg-info/entry_points.txt +0 -0
  15. {punit-1.8.1 → punit-1.9.2}/src/pUnit.egg-info/top_level.txt +0 -0
  16. {punit-1.8.1 → punit-1.9.2}/src/punit/TestResult.py +0 -0
  17. {punit-1.8.1 → punit-1.9.2}/src/punit/assertions/__init__.py +0 -0
  18. {punit-1.8.1 → punit-1.9.2}/src/punit/assertions/collections.py +0 -0
  19. {punit-1.8.1 → punit-1.9.2}/src/punit/assertions/exceptions.py +0 -0
  20. {punit-1.8.1 → punit-1.9.2}/src/punit/assertions/numeric.py +0 -0
  21. {punit-1.8.1 → punit-1.9.2}/src/punit/assertions/strings.py +0 -0
  22. {punit-1.8.1 → punit-1.9.2}/src/punit/discovery/TestModuleDiscovery.py +0 -0
  23. {punit-1.8.1 → punit-1.9.2}/src/punit/discovery/__init__.py +0 -0
  24. {punit-1.8.1 → punit-1.9.2}/src/punit/facts/Fact.py +0 -0
  25. {punit-1.8.1 → punit-1.9.2}/src/punit/facts/FactManager.py +0 -0
  26. {punit-1.8.1 → punit-1.9.2}/src/punit/facts/__init__.py +0 -0
  27. {punit-1.8.1 → punit-1.9.2}/src/punit/filters/Filter.py +0 -0
  28. {punit-1.8.1 → punit-1.9.2}/src/punit/filters/FilterManager.py +0 -0
  29. {punit-1.8.1 → punit-1.9.2}/src/punit/filters/__init__.py +0 -0
  30. {punit-1.8.1 → punit-1.9.2}/src/punit/metadata/CallableMetadata.py +0 -0
  31. {punit-1.8.1 → punit-1.9.2}/src/punit/metadata/__init__.py +0 -0
  32. {punit-1.8.1 → punit-1.9.2}/src/punit/py.typed +0 -0
  33. {punit-1.8.1 → punit-1.9.2}/src/punit/reports/HtmlReportGenerator.py +0 -0
  34. {punit-1.8.1 → punit-1.9.2}/src/punit/reports/JUnitReportGenerator.py +0 -0
  35. {punit-1.8.1 → punit-1.9.2}/src/punit/reports/JsonReportGenerator.py +0 -0
  36. {punit-1.8.1 → punit-1.9.2}/src/punit/reports/__init__.py +0 -0
  37. {punit-1.8.1 → punit-1.9.2}/src/punit/results/__init__.py +0 -0
  38. {punit-1.8.1 → punit-1.9.2}/src/punit/results/fails.py +0 -0
  39. {punit-1.8.1 → punit-1.9.2}/src/punit/setups/Setup.py +0 -0
  40. {punit-1.8.1 → punit-1.9.2}/src/punit/setups/SetupManager.py +0 -0
  41. {punit-1.8.1 → punit-1.9.2}/src/punit/setups/__init__.py +0 -0
  42. {punit-1.8.1 → punit-1.9.2}/src/punit/teardowns/Teardown.py +0 -0
  43. {punit-1.8.1 → punit-1.9.2}/src/punit/teardowns/TeardownManager.py +0 -0
  44. {punit-1.8.1 → punit-1.9.2}/src/punit/teardowns/__init__.py +0 -0
  45. {punit-1.8.1 → punit-1.9.2}/src/punit/theories/Theory.py +0 -0
  46. {punit-1.8.1 → punit-1.9.2}/src/punit/theories/TheoryManager.py +0 -0
  47. {punit-1.8.1 → punit-1.9.2}/src/punit/theories/__init__.py +0 -0
  48. {punit-1.8.1 → punit-1.9.2}/src/punit/traits/Trait.py +0 -0
  49. {punit-1.8.1 → punit-1.9.2}/src/punit/traits/TraitManager.py +0 -0
  50. {punit-1.8.1 → punit-1.9.2}/src/punit/traits/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pUnit
3
- Version: 1.8.1
3
+ Version: 1.9.2
4
4
  Summary: A modernized unit-test framework for Python.
5
5
  Author-email: Shaun Wilson <mrshaunwilson@msn.com>
6
6
  License: MIT License
@@ -36,6 +36,7 @@ Classifier: Intended Audience :: Developers
36
36
  Requires-Python: >=3.11
37
37
  Description-Content-Type: text/markdown
38
38
  License-File: LICENSE
39
+ Requires-Dist: hazrakah
39
40
  Provides-Extra: dev
40
41
  Requires-Dist: coverage; extra == "dev"
41
42
  Requires-Dist: mypy; extra == "dev"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pUnit"
3
- version = "1.8.1"
3
+ version = "1.9.2"
4
4
  description = "A modernized unit-test framework for Python."
5
5
  keywords = ["test", "unittest", "unit-test", "xUnit", "nUnit", "pytest"]
6
6
  authors = [
@@ -16,6 +16,7 @@ classifiers = [
16
16
  "Intended Audience :: Developers"
17
17
  ]
18
18
  dependencies = [
19
+ "hazrakah"
19
20
  ]
20
21
 
21
22
  [project.optional-dependencies]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pUnit
3
- Version: 1.8.1
3
+ Version: 1.9.2
4
4
  Summary: A modernized unit-test framework for Python.
5
5
  Author-email: Shaun Wilson <mrshaunwilson@msn.com>
6
6
  License: MIT License
@@ -36,6 +36,7 @@ Classifier: Intended Audience :: Developers
36
36
  Requires-Python: >=3.11
37
37
  Description-Content-Type: text/markdown
38
38
  License-File: LICENSE
39
+ Requires-Dist: hazrakah
39
40
  Provides-Extra: dev
40
41
  Requires-Dist: coverage; extra == "dev"
41
42
  Requires-Dist: mypy; extra == "dev"
@@ -1,3 +1,4 @@
1
+ hazrakah
1
2
 
2
3
  [dev]
3
4
  coverage
@@ -15,8 +15,8 @@ from .assertions.exceptions import raises
15
15
  from .assertions.numeric import approx
16
16
 
17
17
 
18
- __version__ = '1.8.1'
19
- __commit__ = 'faca395'
18
+ __version__ = '1.9.2'
19
+ __commit__ = '4f7d92b'
20
20
  __all__ = [
21
21
  '__version__', '__commit__',
22
22
  'assertions',
@@ -9,10 +9,12 @@ from pathlib import Path
9
9
 
10
10
  from .cli import CommandLineInterface
11
11
  from .discovery import TestModuleDiscovery
12
+ from .facts.FactManager import FactManager
12
13
  from .reports import HtmlReportGenerator, JUnitReportGenerator, JsonReportGenerator
13
14
  from .runner import TestRunner
14
15
  from .setups.SetupManager import SetupManager
15
16
  from .teardowns.TeardownManager import TeardownManager
17
+ from .theories.TheoryManager import TheoryManager
16
18
 
17
19
 
18
20
  async def async_main() -> None:
@@ -32,13 +34,27 @@ async def async_main() -> None:
32
34
  sys.path.append(src_path)
33
35
  if cwd_path not in sys.path:
34
36
  sys.path.append(cwd_path)
35
- test_module_discovery = TestModuleDiscovery(
36
- os.path.join(cli.workdir, cli.test_package_name),
37
- cli.includePatterns,
38
- cli.excludePatterns,
39
- cli)
40
- test_module_discovery.discover()
41
- test_runner = TestRunner(cli.test_package_name, test_module_discovery.filenames, cli)
37
+ test_runner: TestRunner
38
+ if cli.files:
39
+ dotnames = []
40
+ for filepath in cli.files:
41
+ rel = os.path.relpath(os.path.abspath(filepath), cli.workdir)
42
+ dotnames.append(
43
+ rel[:-3].replace('\\', '/').replace('/', '.')
44
+ )
45
+ FactManager.instance().excludeTraits = cli.excludeTraits
46
+ FactManager.instance().includeTraits = cli.includeTraits
47
+ TheoryManager.instance().excludeTraits = cli.excludeTraits
48
+ TheoryManager.instance().includeTraits = cli.includeTraits
49
+ test_runner = TestRunner('', dotnames, cli)
50
+ else:
51
+ test_module_discovery = TestModuleDiscovery(
52
+ os.path.join(cli.workdir, cli.test_package_name),
53
+ cli.includePatterns,
54
+ cli.excludePatterns,
55
+ cli)
56
+ test_module_discovery.discover()
57
+ test_runner = TestRunner(cli.test_package_name, test_module_discovery.filenames, cli)
42
58
  results = await test_runner.run()
43
59
  total_time = time.time() - start_time
44
60
  failure_count = 0
@@ -43,6 +43,7 @@ class CommandLineInterface:
43
43
  __test_package_name: str | None
44
44
  __verbose: bool
45
45
  __workdir: str | None
46
+ __files: list[str]
46
47
 
47
48
  def __init__(self) -> None:
48
49
  self.__aliases = dict[str, str]()
@@ -61,6 +62,7 @@ class CommandLineInterface:
61
62
  self.__test_package_name = 'tests'
62
63
  self.__workdir = os.path.curdir
63
64
  self.__verbose = False
65
+ self.__files = []
64
66
 
65
67
  def __parse(self, argv: list[str]) -> CommandLineInterface:
66
68
  """
@@ -111,6 +113,9 @@ class CommandLineInterface:
111
113
  extractAliasPath = False
112
114
  self.__aliases[aliasName] = arg
113
115
  continue
116
+ elif arg.endswith('.py') and not arg.startswith('-'):
117
+ self.__files.append(arg)
118
+ continue
114
119
  elif self.__workdir is None:
115
120
  self.__workdir = arg
116
121
  continue
@@ -239,10 +244,14 @@ class CommandLineInterface:
239
244
  def no_pathfix(self) -> bool:
240
245
  return self.__no_pathfix
241
246
 
247
+ @property
248
+ def files(self) -> list[str]:
249
+ return self.__files
250
+
242
251
  def print_help(self) -> None:
243
252
  self.print_version()
244
253
  print("""
245
- Usage: python3 -m punit [-h|--help]
254
+ Usage: python3 -m punit [-h|--help] [FILE ...]
246
255
  [-q|--quiet] [-v|--verbose]
247
256
  [-z|--failfast]
248
257
  [-p|--test-package NAME]
@@ -299,6 +308,12 @@ Options:
299
308
  If `--report` is used, instead of writing to stdout
300
309
  write to FILENAME. In this case `--report` does not
301
310
  suppress any program output.
311
+ FILE
312
+ One or more .py files to run directly.
313
+ When any FILE is specified, only those files are tested;
314
+ -p/--test-package, --include, and --exclude patterns on
315
+ discovered files are ignored (test filtering via -f/-t
316
+ still applies).
302
317
  """)
303
318
  os._exit(0)
304
319
 
@@ -333,9 +348,14 @@ Options:
333
348
  self.__includePatterns.append('*.py')
334
349
  # always exclude dunder files
335
350
  self.__excludePatterns.append('/__*__')
351
+ if self.__files:
352
+ for fpath in self.__files:
353
+ if not os.path.isfile(fpath):
354
+ print(f'File not found: {fpath}')
355
+ os._exit(1)
336
356
 
337
357
  @staticmethod
338
- def parse(argv: list[str] = sys.argv) -> CommandLineInterface:
358
+ def parse(argv: list[str] = sys.argv[1:]) -> CommandLineInterface:
339
359
  result = CommandLineInterface().__parse(argv)
340
360
  result.validate()
341
361
  return result
@@ -233,13 +233,19 @@ class TestRunner:
233
233
  test_package_path = os.path.join(os.path.abspath(os.curdir), self.__test_package_name).replace('\\', '/')
234
234
  for filename in self.__filenames:
235
235
  ts = time.time()
236
- module_import_name = filename.replace(test_package_path, '').replace('/', '.')
237
- if module_import_name.endswith('.py'):
238
- module_import_name = module_import_name[:-3]
236
+ if not self.__test_package_name:
237
+ module_import_name = filename
238
+ else:
239
+ module_import_name = filename.replace(test_package_path, '').replace('/', '.')
240
+ if module_import_name.endswith('.py'):
241
+ module_import_name = module_import_name[:-3]
239
242
  module_report_name = module_import_name.lstrip('.')
240
243
  try:
241
244
  host_name: str = socket.gethostname()
242
- test_module = importlib.import_module(module_import_name, self.__test_package_name)
245
+ if not self.__test_package_name:
246
+ test_module = importlib.import_module(module_import_name)
247
+ else:
248
+ test_module = importlib.import_module(module_import_name, self.__test_package_name)
243
249
 
244
250
  # execute all facts
245
251
  await self.__run_facts(host_name, test_module, filename, module_report_name, results)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes