Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QGIS and Python installed correctly, test fails on comparing files.
TESTED WITH DIFFERENT VERSION OF PYTHON TEST FILE AND DIFFLIB LINE BY LINE SHOWS NO DIFFERENCES BUT FILECMP FAILS -------------------------------------------------------------------------- Run export QGIS_PREFIX_PATH="/usr" ============================= test session starts ============================== platform linux -- Python 3.10.12, pytest-8.2.2, pluggy-1.5.0 PyQt6 6.7.0 -- Qt runtime 6.7.1 -- Qt compiled 6.7.1 rootdir: /home/runner/work/GRASS-GIS-Q-GIS-color-table-conversion-BACKUP/GRASS-GIS-Q-GIS-color-table-conversion-BACKUP plugins: qt-4.4.0 collected 5 items test/test_qgis_color_func.py ....F [100%] =================================== FAILURES =================================== _______________________________ test_OutputFile ________________________________ def test_OutputFile(): """ Check if the output table is created correctly. Compare it with reference file. """ # Get the GRASS color table GRASStable_path = getCORINEtable() # Create a temporary qml file tempdir = tempfile.mkdtemp() Tempfile = os.path.join(tempdir, "tempfile.qml") # Convert the GRASS color table to QGIS format convert_color_table_grass_to_qgis(GRASStable_path, Tempfile) # Normalize line endings of the generated QML file with open(Tempfile, 'r') as f: content = f.read() normalized_content = normalize_line_endings(content) write_with_lf_line_endings(normalized_content, Tempfile) # Check if the output table is created correctly script_dir = Path(__file__).resolve().parent # Construct the path to the target directory target_dir = script_dir.parent / "test" / "reference" # Specify the filename you want to access filename = "corine.qml" # Create the full path to the file CORINE_file_path = target_dir / filename with open(Tempfile, 'r') as gen_file: gen_content = gen_file.read() with open(CORINE_file_path, 'r') as ref_file: ref_content = ref_file.read() # Compare content line by line gen_lines = gen_content.splitlines(keepends=True) ref_lines = ref_content.splitlines(keepends=True) diff = difflib.unified_diff(gen_lines, ref_lines, fromfile='generated', tofile='reference') diff_str = ''.join(diff) if diff_str: print("Differences found:\n", diff_str) else: print("No differences found.") > assert filecmp.cmp(Tempfile, CORINE_file_path, shallow=False) E AssertionError: assert False E + where False = <function cmp at 0x7f578b87dea0>('/tmp/tmp53igm9nx/tempfile.qml', PosixPath('/home/runner/work/GRASS-GIS-Q-GIS-color-table-conversion-BACKUP/GRASS-GIS-Q-GIS-color-table-conversion-BACKUP/test/reference/corine.qml'), shallow=False) E + where <function cmp at 0x7f578b87dea0> = filecmp.cmp test/test_qgis_color_func.py:199: AssertionError ----------------------------- Captured stdout call ----------------------------- No differences found. =========================== short test summary info ============================ FAILED test/test_qgis_color_func.py::test_OutputFile - AssertionError: assert False + where False = <function cmp at 0x7f578b87dea0>('/tmp/tmp53igm9nx/tempfile.qml', PosixPath('/home/runner/work/GRASS-GIS-Q-GIS-color-table-conversion-BACKUP/GRASS-GIS-Q-GIS-color-table-conversion-BACKUP/test/reference/corine.qml'), shallow=False) + where <function cmp at 0x7f578b87dea0> = filecmp.cmp ========================= 1 failed, 4 passed in 0.46s ========================== Error: Process completed with exit code 1.
- Loading branch information