1
0
forked from GitHub/gf-core

make tests executable from a different path

This commit is contained in:
Krasimir Angelov
2023-01-26 09:44:36 +01:00
parent 64d439601d
commit 8cac0610f8
2 changed files with 17 additions and 10 deletions

View File

@@ -1,20 +1,24 @@
import os import os
import os.path
import pytest import pytest
from pgf import * from pgf import *
pgf_path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))+"/haskell/tests/"
# readPGF # readPGF
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def PGF(): def PGF():
return readPGF("../haskell/tests/basic.pgf") return readPGF(pgf_path+"basic.pgf")
def test_readPGF_non_existent(): def test_readPGF_non_existent():
with pytest.raises(FileNotFoundError): with pytest.raises(FileNotFoundError):
readPGF("../haskell/tests/abc.pgf") readPGF(pgf_path+"abc.pgf")
def test_readPGF_GF(): def test_readPGF_GF():
with pytest.raises(PGFError): with pytest.raises(PGFError):
readPGF("../haskell/tests/basic.gf") readPGF(pgf_path+"basic.gf")
def test_readPGF_NGF(NGF): def test_readPGF_NGF(NGF):
with pytest.raises(PGFError): with pytest.raises(PGFError):
@@ -24,17 +28,17 @@ def test_readPGF_NGF(NGF):
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def NGF(): def NGF():
ngf = bootNGF("../haskell/tests/basic.pgf", "./basic.ngf") ngf = bootNGF(pgf_path+"basic.pgf", "./basic.ngf")
yield ngf yield ngf
os.remove("./basic.ngf") os.remove("./basic.ngf")
def test_bootNGF_non_existent(): def test_bootNGF_non_existent():
with pytest.raises(FileNotFoundError): with pytest.raises(FileNotFoundError):
bootNGF("../haskell/tests/abc.pgf", "./abc.ngf") bootNGF(pgf_path+"abc.pgf", "./abc.ngf")
def test_bootNGF_GF(): def test_bootNGF_GF():
with pytest.raises(PGFError): with pytest.raises(PGFError):
bootNGF("../haskell/tests/basic.gf", "./abc.ngf") bootNGF(pgf_path+"basic.gf", "./abc.ngf")
def test_bootNGF_NGF(NGF): def test_bootNGF_NGF(NGF):
with pytest.raises(PGFError): with pytest.raises(PGFError):
@@ -42,7 +46,7 @@ def test_bootNGF_NGF(NGF):
def test_bootNGF_existing(NGF): def test_bootNGF_existing(NGF):
with pytest.raises(FileExistsError): with pytest.raises(FileExistsError):
bootNGF("../haskell/tests/basic.pgf", "./basic.ngf") bootNGF(pgf_path+"basic.pgf", "./basic.ngf")
# readNGF # readNGF
@@ -52,11 +56,11 @@ def test_readNGF_non_existent():
def test_readNGF_GF(): def test_readNGF_GF():
with pytest.raises(PGFError): with pytest.raises(PGFError):
readNGF("../haskell/tests/basic.gf") readNGF(pgf_path+"basic.gf")
def test_readNGF_PGF(): def test_readNGF_PGF():
with pytest.raises(PGFError): with pytest.raises(PGFError):
readNGF("../haskell/tests/basic.pgf") readNGF(pgf_path+"basic.pgf")
def test_readNGF(NGF): def test_readNGF(NGF):
PGF = readNGF("./basic.ngf") PGF = readNGF("./basic.ngf")

View File

@@ -1,13 +1,16 @@
import os.path
import pytest import pytest
from pgf import * from pgf import *
import math import math
pgf_path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))+"/haskell/tests/"
ty = readType("(N -> N) -> P (s z)") ty = readType("(N -> N) -> P (s z)")
prob = math.pi prob = math.pi
@pytest.fixture(scope="function") @pytest.fixture(scope="function")
def gr1(): def gr1():
gr = readPGF("../haskell/tests/basic.pgf") gr = readPGF(pgf_path+"basic.pgf")
yield gr yield gr
@pytest.fixture(scope="function") @pytest.fixture(scope="function")