Skip to content

Commit

Permalink
Fix file comparison on windows (#2960)
Browse files Browse the repository at this point in the history
### Changes

Compare content of files instead of `filecmp.cmp`

### Reason for changes 
 
```
>       assert filecmp.cmp(tmp_path_to_graph, REF_DOT_REPRESENTATION_GRAPH_PATH)
E       AssertionError: assert False
```

Files is differ because used differ line separators for WIN in UNIX.


### Tests

nightly/job/windows/job/precommit_common/40/
  • Loading branch information
AlexanderDokuchaev authored Sep 11, 2024
1 parent 387aa30 commit b9dc0b6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/common/graph/test_dot_file_rw.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import filecmp

from copy import deepcopy
from pathlib import Path

Expand Down Expand Up @@ -47,7 +47,9 @@ def test_writing_does_not_modify_original_graph(tmp_path: Path, ref_graph: nx.Di
def test_colons_are_replaced_in_written_dot_file(tmp_path: Path, ref_graph: nx.DiGraph):
tmp_path_to_graph = tmp_path / "graph.dot"
write_dot_graph(ref_graph, tmp_path_to_graph)
assert filecmp.cmp(tmp_path_to_graph, REF_DOT_REPRESENTATION_GRAPH_PATH)
ref = REF_DOT_REPRESENTATION_GRAPH_PATH.read_text()
act = tmp_path_to_graph.read_text()
assert ref == act


def test_read_dot_file_gives_graph_with_colons(tmp_path: Path, ref_graph: nx.DiGraph):
Expand Down

0 comments on commit b9dc0b6

Please sign in to comment.