Skip to content

Commit

Permalink
Fix fixture g52.graphml
Browse files Browse the repository at this point in the history
  • Loading branch information
EhsanBitaraf committed Oct 17, 2023
1 parent 1c0f8c9 commit 03374fc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pyinstaller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10
python-version: 3.11.3

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down
17 changes: 14 additions & 3 deletions tests/fixtures/graph_52.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

import os
import pytest
import networkx as nx

from triplea.config.settings import ROOT


"""
This is a pytest fixture that sets up a graph object by reading a graphml file.
Expand All @@ -12,7 +15,9 @@
def graph52():
# set up code goes here
try:
G = nx.read_graphml('tests\\fixtures\\g52.graphml')
path_graph = os.path.join(ROOT, "tests" , "fixtures","g52.graphml")
G = nx.read_graphml(path_graph)
# G = nx.read_graphml('tests\\fixtures\\g52.graphml')
except FileNotFoundError:
G = nx.read_graphml('g52.graphml')
print("File 'g52.graphml' does not exist.")
Expand All @@ -26,12 +31,18 @@ def graph52():
def graph52_instance():
# set up code goes here
try:
G = nx.read_graphml('tests\\fixtures\\g52.graphml')
path_graph = os.path.join(ROOT, "tests" , "fixtures","g52.graphml")
G = nx.read_graphml(path_graph)
# G = nx.read_graphml('tests\\fixtures\\g52.graphml')
except FileNotFoundError:
G = nx.read_graphml('g52.graphml')
print("File 'g52.graphml' does not exist.")
return G
except nx.NetworkXError:
print("Error reading 'g52.graphml' file.")
else:
return G
return G




12 changes: 12 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import os
import pathlib
from click.testing import CliRunner
from triplea.cli.main import cli
from triplea import __version__
import networkx as nx
from tests.fixtures.graph_52 import graph52
from triplea.config.settings import SETTINGS
from triplea.config.settings import ROOT


def test_cli_version():
runner = CliRunner()
Expand All @@ -16,6 +21,13 @@ def test_cli_version():
# if __name__ == "__main__":
# test_cli_version()

def test_path():
# root = pathlib.Path(__file__).resolve()
root = os.path.join(ROOT, "tests" , "fixtures")
# assert ROOT / "tests" == ""
assert root == ""


def test_fixture_graph52(graph52):
assert isinstance(graph52, nx.Graph)
assert len(graph52.nodes) == 962
Expand Down

0 comments on commit 03374fc

Please sign in to comment.