Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-read variables from standard configuration anew for every test-case #35

Open
gridhead opened this issue Oct 15, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@gridhead
Copy link
Member

As the CliRunner (used for testing Click applications) does not invoke the commands for testing as a separate subprocess in an interactive shell, the variables that have been globally changed during the first test case - remain changed (and are hence read in their changed form) in the consequent test cases. This leads to the subsequent test cases failing due to the fact that these variables have not been re-initialized to their original value.

One such example is stated below where the variable tnfsindx (from the file standard.py) is used to track the number of branches the assets of which have been migrated from the source namespace to the destination namespace. After the first successful run of a test case for migrating all branches, the count is not re-initialized to 0 for the subsequent test cases. Hence, the exit criteria cannot be reliably determined from the following logic.

if standard.tnfsindx == standard.tnfsqant:
    success("Namespace assets transfer succeeded!")
    sys.exit(0)
elif 0 < standard.tnfsindx < standard.tnfsqant:
    warning("Namespace assets transfer partially completed!")
    sys.exit(2)
else:
    failure("Namespace assets transfer failed!")
    sys.exit(1)

The above snippet is taken from the file repo.py. The exit criteria of the command is determined by comparing the values of tnfsindx (which remains changed in every test case and keeps getting read in its changed form across multiple test cases) with the tnfsqant (from the file standard.py) - thus causing unreliable exit criteria and failing tests. One possible workarounds for this would be to reset the variables explicitly right before exitting.

if standard.tnfsindx == standard.tnfsqant:
    success("Namespace assets transfer succeeded!")
    standard.tnfsindx = 0
    sys.exit(0)
elif 0 < standard.tnfsindx < standard.tnfsqant:
    warning("Namespace assets transfer partially completed!")
    standard.tnfsindx = 0
    sys.exit(2)
else:
    failure("Namespace assets transfer failed!")
    standard.tnfsindx = 0
    sys.exit(1)

But that is not an elegant code.

And that is not even a solution.

We need a solution.

@gridhead gridhead added the bug Something isn't working label Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant