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

Some unit tests cannot be run independently #4611

Closed
fabioz opened this issue Jan 18, 2023 · 1 comment
Closed

Some unit tests cannot be run independently #4611

fabioz opened this issue Jan 18, 2023 · 1 comment

Comments

@fabioz
Copy link
Contributor

fabioz commented Jan 18, 2023

I cannot run the tests on my local machine by downloading the code going into the RF dir and executing:

python utest/run.py -q running

The errors I have are below (after improving the output a bit with the PR: #4610).

The errors seem to happen because the import path isn't setup (so, I guess imports are failing, but I'm not sure how to print that additional info)...

i.e.: in test_imports.TestImports.test_create I can't see how the keyword My Test Keyword can be loaded from the robotframework\utest\resources\test_resource.txt.

Is some additional setup needed in order to run these tests?

(py311_tests) λ python utest/run.py -q running
======================================================================
FAIL: test_create (test_imports.TestImports.test_create)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 33, in run_and_check_pass
    assert_suite(result, 'Suite', 'PASS')
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 16, in assert_suite
    assert_equal(suite.status, status)
  File "X:\robocorpws\robotframework\utest\..\src\robot\utils\asserts.py", line 181, in assert_equal
    _report_inequality(first, second, '!=', msg, values, formatter)
  File "X:\robocorpws\robotframework\utest\..\src\robot\utils\asserts.py", line 230, in _report_inequality
    raise AssertionError(msg)
AssertionError: FAIL != PASS

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 52, in test_create
    self.run_and_check_pass(suite)
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 41, in run_and_check_pass
    raise AssertionError('\n'.join(full_msg)) from e
AssertionError: No keyword with name 'My Test Keyword' found.

======================================================================
FAIL: test_resource (test_imports.TestImports.test_resource)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 33, in run_and_check_pass
    assert_suite(result, 'Suite', 'PASS')
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 16, in assert_suite
    assert_equal(suite.status, status)
  File "X:\robocorpws\robotframework\utest\..\src\robot\utils\asserts.py", line 181, in assert_equal
    _report_inequality(first, second, '!=', msg, values, formatter)
  File "X:\robocorpws\robotframework\utest\..\src\robot\utils\asserts.py", line 230, in _report_inequality
    raise AssertionError(msg)
AssertionError: FAIL != PASS

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 67, in test_resource
    self.run_and_check_pass(suite)
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 41, in run_and_check_pass
    raise AssertionError('\n'.join(full_msg)) from e
AssertionError: No keyword with name 'My Test Keyword' found.

======================================================================
FAIL: test_variables (test_imports.TestImports.test_variables)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 33, in run_and_check_pass
    assert_suite(result, 'Suite', 'PASS')
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 16, in assert_suite
    assert_equal(suite.status, status)
  File "X:\robocorpws\robotframework\utest\..\src\robot\utils\asserts.py", line 181, in assert_equal
    _report_inequality(first, second, '!=', msg, values, formatter)
  File "X:\robocorpws\robotframework\utest\..\src\robot\utils\asserts.py", line 230, in _report_inequality
    raise AssertionError(msg)
AssertionError: FAIL != PASS

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 76, in test_variables
    self.run_and_check_pass(suite)
  File "X:\robocorpws\robotframework\utest\running\test_imports.py", line 41, in run_and_check_pass
    raise AssertionError('\n'.join(full_msg)) from e
AssertionError: Variable '${MY_VARIABLE}' not found.

----------------------------------------------------------------------
Ran 296 tests in 2.281s

FAILED (failures=3)
@fabioz fabioz changed the title Cannot run tests on local machine Cannot run test_imports.TestImports after cloning Robotframework and executing python utest/run.py -q running Jan 18, 2023
@fabioz fabioz changed the title Cannot run test_imports.TestImports after cloning Robotframework and executing python utest/run.py -q running Cannot run test_imports.TestImports after cloning Robot Framework and executing python utest/run.py -q running Jan 18, 2023
@pekkaklarck
Copy link
Member

The failing tests import a resource file that exists in utest/resources from that should be in PYTHONPATH. utest/run.py should set that directory into PYTHONPATH but doesn't. Apparently it's set there by some other tests, because if you run all unit tests also these tests succeed. Anyway, easy to fix.

@pekkaklarck pekkaklarck added this to the v6.1 milestone Feb 10, 2023
@pekkaklarck pekkaklarck changed the title Cannot run test_imports.TestImports after cloning Robot Framework and executing python utest/run.py -q running Some unit tests cannot be run independently Feb 10, 2023
yanne pushed a commit that referenced this issue Mar 18, 2023
Without this some tests fail when running

    utest/run.py running

Apparently this path is set to PYTHONPATH by some tests, because
running all tests succeeded.

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

No branches or pull requests

2 participants