Skip to content

Exclude tests in class #1057

@gragib

Description

@gragib

Let's say I have a file named JsonGenerator.py with the following content:

class JsonGenerator(Test):
    def test(self):
        ...

    @property
    def testrail_props(self):
        ...

How do I run JsonGenerator.py:JsonGenerator.test? Any attempt causes something like this (redacted):

# slash run JsonGenerator.py:JsonGenerator.test
Traceback (most recent call last):
  File "C:\Python\39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python\39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File ".env\Scripts\slash.EXE\__main__.py", line 7, in <module>
  File ".env\lib\site-packages\slash\frontend\main.py", line 71, in main_entry_point
    sys.exit(main())
  File ".env\lib\site-packages\slash\frontend\main.py", line 47, in main
    returned = func(args)
  File ".env\lib\site-packages\slash\frontend\slash_list.py", line 70, in slash_list
    runnables = loader.get_runnables(itertools.chain(parsed_args.paths, iter_suite_file_paths(parsed_args.suite_files)))
  File ".env\lib\site-packages\slash\loader.py", line 57, in get_runnables
    sources = self._generate_repeats(self._generate_test_sources(paths))
  File ".env\lib\site-packages\slash\loader.py", line 82, in _generate_repeats
    for test in tests:
  File ".env\lib\site-packages\slash\loader.py", line 124, in <genexpr>
    return (t for t in iterator if matcher is None or matcher.matches(t.__slash__))
  File ".env\lib\site-packages\slash\loader.py", line 124, in <genexpr>
    return (t for t in iterator if matcher is None or matcher.matches(t.__slash__))
  File ".env\lib\site-packages\slash\loader.py", line 146, in _iter_test_address
    tests = list(self._iter_path(path))
  File ".env\lib\site-packages\slash\loader.py", line 209, in _iter_paths
    for runnable in self._iter_runnable_tests_in_module(file_path, module):
  File ".env\lib\site-packages\slash\loader.py", line 252, in _iter_runnable_tests_in_module
    for test in factory.generate_tests(fixture_store=context.session.fixture_store):
  File ".env\lib\site-packages\slash\core\runnable_test_factory.py", line 55, in generate_tests
    for test in self._generate_tests(fixture_store):
  File ".env\lib\site-packages\slash\core\test.py", line 31, in _generate_tests
    for fixture_variation in self._iter_parametrization_variations(test_method_name, fixture_store):
  File ".env\lib\site-packages\slash\core\test.py", line 43, in _iter_parametrization_variations
    return fixture_store.iter_parametrization_variations(methods=itertools.chain(
  File ".env\lib\site-packages\slash\core\fixtures\fixture_store.py", line 317, in iter_parametrization_variations
    variation_factory.add_needed_fixtures_from_method(method)
  File ".env\lib\site-packages\slash\core\variation_factory.py", line 34, in add_needed_fixtures_from_method
    self._add_needed_fixtures_from_function(method)
  File ".env\lib\site-packages\slash\core\variation_factory.py", line 49, in _add_needed_fixtures_from_function
    args = get_arguments(func)
  File ".env\lib\site-packages\slash\utils\python.py", line 79, in get_arguments
    returned = [FunctionArgument.from_parameter(p) for name, p in inspect.signature(func).parameters.items()] # pylint: disable=no-member
  File "C:\Python\39\lib\inspect.py", line 3113, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "C:\Python\39\lib\inspect.py", line 2862, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File "C:\Python\39\lib\inspect.py", line 2261, in _signature_from_callable
    raise TypeError('{!r} is not a callable object'.format(obj))

Renaming testrail_props to _testrail_props fixes the issue, but that's an undesirable solution for reasons I can't elaborate on in a public forum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions