You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 filestandard.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 to0
for the subsequent test cases. Hence, the exit criteria cannot be reliably determined from the following logic.The above snippet is taken from the file
repo.py
. The exit criteria of the command is determined by comparing the values oftnfsindx
(which remains changed in every test case and keeps getting read in its changed form across multiple test cases) with thetnfsqant
(from the filestandard.py
) - thus causing unreliable exit criteria and failing tests. One possible workarounds for this would be to reset the variables explicitly right before exitting.But that is not an elegant code.
And that is not even a solution.
We need a solution.
The text was updated successfully, but these errors were encountered: