Skip to content

Commit

Permalink
Fix unit tests which loads data from current dir
Browse files Browse the repository at this point in the history
Change current dir to the parent dir of the test.
  • Loading branch information
vsbogd committed Mar 30, 2024
1 parent 591b58c commit 5f223ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import os

from hyperon import atoms_are_equivalent

Expand Down Expand Up @@ -37,6 +38,9 @@ def areEqualMettaRunResults(a, b):
return False
return True

def change_dir_to_parent_of(file):
os.chdir(os.path.dirname(file))

class HyperonTestCase(unittest.TestCase):

def __init__(self, methodName):
Expand Down
4 changes: 4 additions & 0 deletions python/tests/test_extend.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import unittest

from hyperon import *
from test_common import change_dir_to_parent_of

class ExtendTest(unittest.TestCase):

def setUp(self):
change_dir_to_parent_of(__file__)

def test_extend(self):
'''
This test verifies that importing from a python-implemnted module along with @register_atoms and @register_tokens works
Expand Down
3 changes: 3 additions & 0 deletions python/tests/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

class LoadAsciiTest(HyperonTestCase):

def setUp(self):
change_dir_to_parent_of(__file__)

def test_load(self):
metta = MeTTa()
test_file = "test_load.metta"
Expand Down

0 comments on commit 5f223ca

Please sign in to comment.