Skip to content

test: add unit tests for ProgressReporterPlugin._get_test_name() #708

@aitestino

Description

@aitestino

Description

PR #655 rewrote _get_test_name() in plugin.py to use the NAC_TEST_TEST_DIR environment variable for computing relative test names. This is the core bug fix for #653, but it has zero unit test coverage. The only coverage comes from E2E tests, which validate stdout output but can't pinpoint failures in the name computation logic.

Missing Test Cases

  1. Happy path: env var set, test file under test_dir → dot-notation name
  2. Nested directories: test_dir/nrfu/verify_bgp.pynrfu.verify_bgp
  3. Env var unset: falls back to bare file stem, logs warning
  4. Path outside test_dir: relative_to() raises ValueError → falls back to stem, logs warning
  5. Symlinked test file: symlink inside test_dir pointing outside → still produces relative name (the entire point of fix: replace resolve() with absolute() in path comparisons to handle symlinked test files #656)
  6. Test file directly in test_dir root: test_dir/verify_foo.pyverify_foo

Suggested File

tests/unit/pyats_core/progress/test_plugin.py

Context

#655 rewrote this method. The E2E tests (test_stdout_pyats_test_names_are_relative, test_stdout_symlinked_test_has_relative_name) provide black-box coverage, but unit tests are needed to validate the logic directly and make debugging easier when failures occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions