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

Improve expect_error feedback #16

Merged
merged 10 commits into from
May 17, 2021
Merged

Conversation

Blind4Basics
Copy link
Contributor

previously:

when execting a specific error, if any other error is ancountered, the test fails without any useful feedback
suggestion:

added {actual error} should be {expected error} to the message
note:

this time, I updated the related test output fixture. I checked manually that the behavior was exactly the same (hopefuly... x) )

@Blind4Basics
Copy link
Contributor Author

damn it... x( There I don't know what to do anymore...
Waiting for feedback.

@kazk
Copy link
Member

kazk commented May 10, 2021

You don't need to keep opening new PR to fix. Also, you probably need to update the test code to escape parentheses in expected.

expected = re.sub(
r"(?<=<COMPLETEDIN::>)\d+(?:\.\d+)?", r"\\d+(?:\\.\\d+)?", r.read()
)
self.assertRegex(result.stdout.decode("utf-8"), expected)

@Blind4Basics
Copy link
Contributor Author

\o/

finally passing...

@Blind4Basics
Copy link
Contributor Author

damn it... (I did another change...) I'll check again.

@Blind4Basics
Copy link
Contributor Author

Blind4Basics commented May 17, 2021

good again...

@kazk: I tried to setup the thing to try it locally, but I ended up with the result.stdout.decode("utf-8") being an empty string. No idea why... I had to modify the environment Path object to a string too, otherwise I got errors. No idea what are causing those differencies... (running 3.8.10 on Win7, using VSC)

cheers

@kazk
Copy link
Member

kazk commented May 17, 2021

Can you explain what you did (step by step) and what's failing? Screenshots and/or error messages helps.

The tests are passing here, so I'm not sure what's wrong.

@Blind4Basics
Copy link
Contributor Author

  1. I pasted the two subfolders codewars_test and tests locally
  2. updated the code
  3. ran tests/test_outputs.py

there, I got this kind of error (same kind of message for every test method):

======================================================================
ERROR: test_timeout_passing (__main__.TestOutputs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "...\codewars\CW - utilities\essais CW framework\tests\test_outputs.py", line 18, in test
    result = subprocess.run(
  File "...Programs\Python\Python38\lib\subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "...Programs\Python\Python38\lib\subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "...Programs\Python\Python38\lib\subprocess.py", line 1311, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
TypeError: environment can only contain strings

then I changed this:

# from:
test_func = test_against_expected(
                os.path.join(fixtures_dir, f),
                expected_file,
                {"PYTHONPATH": package_dir},
            )
# to:
test_func = test_against_expected(
                os.path.join(fixtures_dir, f),
                expected_file,
                {"PYTHONPATH": str(package_dir)},
            )

There, the tests are running, but I get this:

======================================================================
FAIL: test_timeout_passing (__main__.TestOutputs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "...\codewars\CW - utilities\essais CW framework\tests\test_outputs.py", line 32, in test
    self.assertRegex(result.stdout.decode("utf-8"), expected)
AssertionError: Regex didn't match: '\n<DESCRIBE::>group 1\n\n<PASSED::>Test Passed\n\n<PASSED::>Test Passed\n\n<COMPLETEDIN::>\\d+(?:\\.\\d+)?\n' not found in ''

@kazk
Copy link
Member

kazk commented May 17, 2021

Confirmed that this is a Windows thing (#17). I don't have Windows, and we don't use Windows, so I'll leave it as is. If you find a fix, please open a PR.

@kazk kazk changed the title enhance expect_error feedback (third try...) Improve expect_error feedback May 17, 2021
@kazk kazk changed the title Improve expect_error feedback Improve expect_error feedback May 17, 2021
tests/test_outputs.py Outdated Show resolved Hide resolved
@kazk kazk merged commit 2d1cf4a into codewars:master May 17, 2021
@Blind4Basics Blind4Basics deleted the expect-error-msg branch May 18, 2021 04:56
@kazk
Copy link
Member

kazk commented May 19, 2021

@Blind4Basics Deployed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants