From 8c842d7e5f77a92ffd4e02bdabd27c904092fdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20H=C3=A9risson?= Date: Wed, 13 Oct 2021 15:08:10 +0200 Subject: [PATCH] tests: fix path --- tests/test_input-format.py | 4 ++-- tests/test_main.py | 21 +++++++++++++++++---- tests/test_misc.py | 4 +--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tests/test_input-format.py b/tests/test_input-format.py index 9e0f417..33eac9d 100644 --- a/tests/test_input-format.py +++ b/tests/test_input-format.py @@ -42,7 +42,7 @@ def test_BadInputFormatCSV_1(self): self.assertRaises( KeyError, parse_rules, - rules_file='data/rules.csv', + rules_file=self.rules_file, input_format='tsv', diameters=diam, outfile=outfile.name @@ -55,7 +55,7 @@ def test_BadInputFormatCSV_2(self): outfile = NamedTemporaryFile(delete=True) self.assertRaises(ValueError, parse_rules, - rules_file='data/rules.csv', + rules_file=self.rules_file, input_format='other', diameters=diam, outfile=outfile.name) diff --git a/tests/test_main.py b/tests/test_main.py index 0fc33dd..ce3f9d9 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -6,7 +6,7 @@ # Generic for test process from unittest import TestCase - +from os import path as os_path # Specific for tool from rrparser import __path__ as pkg_path @@ -18,7 +18,20 @@ class Test_RR(TestCase): diameters = ['2', '4', '6', '8', '10', '12', '14', '16'] - rules_file = 'data/rules.csv' - ref_d2_csv = 'data/out_d2.csv' - ref_d2_tsv = 'data/out_d2.tsv' + data = os_path.join( + os_path.dirname(os_path.realpath(__file__)), + 'data' + ) + rules_file = os_path.join( + data, + 'rules.csv' + ) + ref_d2_csv = os_path.join( + data, + 'out_d2.csv' + ) + ref_d2_tsv = os_path.join( + data, + 'out_d2.tsv' + ) pkg_path = pkg_path diff --git a/tests/test_misc.py b/tests/test_misc.py index 749e67a..3c88e13 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -14,12 +14,10 @@ from rrparser import parse_rules # Specific for tests themselves -from os import stat from itertools import combinations from random import sample, seed from io import open as io_open from tempfile import NamedTemporaryFile -from tarfile import open as tf_open # Cette classe est un groupe de tests. Son nom DOIT commencer @@ -44,7 +42,7 @@ def test_SmallRulesFile_OneDiameter_SpecifyOutfile(self): diam = '2' outfile = NamedTemporaryFile(delete=False) parse_rules( - rules_file = 'data/rules.csv', + rules_file = self.rules_file, outfile = outfile.name, diameters = diam, output_format = format