uyuni-project / terracumber

Wrapper to run terraform and cucumber for Uyuni and SUSE Manager CI testing
0 stars 9 forks source link

Fix broken unit test #15

Open nodeg opened 2 years ago

nodeg commented 2 years ago

Python 3.11.7 was used.

pip install pytest
(...)
pip install -r requirements.txt
(...)

python3 -m unittest
......VAR=555
..Removing tags and fetching from <MagicMock name='Repository().remotes.__getitem__().url' id='4568892752'>...
mytag seems to be a tag
Checking out
Removing tags and fetching from <MagicMock name='Repository().remotes.__getitem__().url' id='4568892752'>...
Checking out
Performing hard reset to ignore local changes
uRemoving tags and fetching from <MagicMock name='Repository().remotes.__getitem__().url' id='4535519568'>...
Checking out
Performing hard reset to ignore local changes
u..umytag seems to be a tag
mytag seems to be a tag
Checking out
Checking out
Performing hard reset to ignore local changes
.Removing tags and fetching from <MagicMock name='Repository().remotes.__getitem__().url' id='4568705552'>...
mytag seems to be a tag
Checking out
...u...........
======================================================================
UNEXPECTED SUCCESS: test_clone_ref_is_tag (test.test_git.TestGit.test_clone_ref_is_tag)
UNEXPECTED SUCCESS: test_create_remote_from_url (test.test_git.TestGit.test_create_remote_from_url)
UNEXPECTED SUCCESS: test_is_remote (test.test_git.TestGit.test_is_remote)
UNEXPECTED SUCCESS: test_sort_test_files_by_mtime (test.test_junit.TestJunit.test_sort_test_files_by_mtime)
----------------------------------------------------------------------
Ran 29 tests in 0.327s

FAILED (unexpected successes=4)
TEST⏎ 
nodeg commented 8 months ago

The current CI tests fail with:

============================= test session starts ==============================
platform linux -- Python 3.11.7, pytest-8.0.0, pluggy-1.4.0
rootdir: /home/runner/work/terracumber/terracumber
plugins: cov-4.1.0
collected 29 items

test/test_config.py .                                                    [  3%]
test/test_cucumber.py ......                                             [ 24%]
test/test_git.py .xx..x..                                                [ 51%]
test/test_junit.py .Fx.                                                  [ 65%]
test/test_mailer.py .                                                    [ 68%]
test/test_terraformer.py .......                                         [ 93%]
/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/coverage/inorout.py:503: CoverageWarning: Module com was never imported. (module-not-imported)
  self.warn(f"Module {pkg} was never imported.", slug="module-not-imported")
/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/coverage/control.py:887: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/pytest_cov/plugin.py:312: CovReportWarning: Failed to generate report: No data to report.

  warnings.warn(CovReportWarning(message))
test/test_utils.py ..                                                    [100%]WARNING: Failed to generate report: No data to report.

=================================== FAILURES ===================================
__________________________ TestJunit.test_get_totals ___________________________

self = <test.test_junit.TestJunit testMethod=test_get_totals>

    def test_get_totals(self):
        totals = {'failures': 3, 'errors': 0, 'skipped': 0, 'passed': 63, 'tests': 66, 'time': 1334.586592}
>       self.assertDictEqual(self.junit.get_totals(), totals)
E       AssertionError: {'fai[29 chars]ped': 0, 'passed': 63, 'tests': 66, 'time': 1334.5865919999999} != {'fai[29 chars]ped': 0, 'passed': 63, 'tests': 66, 'time': 1334.586592}
E         {'errors': 0,
E          'failures': 3,
E          'passed': 63,
E          'skipped': 0,
E          'tests': 66,
E       -  'time': 1334.5865919999999}
E       ?                    ^^^^^^^^
E       
E       +  'time': 1334.586592}
E       ?                    ^

test/test_junit.py:24: AssertionError
=============================== warnings summary ===============================
terracumber/git.py:86
  /home/runner/work/terracumber/terracumber/terracumber/git.py:86: DeprecationWarning: invalid escape sequence '\/'
    if re.match('refs\/tags\/.+', reference):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
- generated xml file: /home/runner/work/terracumber/terracumber/junit/test-results.xml -

---------- coverage: platform linux, python 3.11.7-final-0 -----------

=========================== short test summary info ============================
FAILED test/test_junit.py::TestJunit::test_get_totals - AssertionError: {'fai[29 chars]ped': 0, 'passed': 63, 'tests': 66, 'time': 1334.5865919999999} != {'fai[29 chars]ped': 0, 'passed': 63, 'tests': 66, 'time': 1334.586592}
  {'errors': 0,
   'failures': 3,
   'passed': 63,
   'skipped': 0,
   'tests': 66,
-  'time': 1334.5865919999999}
?                    ^^^^^^^^

+  'time': 1334.586592}
?                    ^
============== 1 failed, 24 passed, 4 xfailed, 1 warning in 1.[51](https://github.com/uyuni-project/terracumber/pull/30/checks#step:5:52)s ==============