Skip to content
This repository was archived by the owner on Mar 2, 2025. It is now read-only.

Commit ad31e2b

Browse files
committed
Migrate to relative config-path parsing (for tox test runs)
1 parent e540932 commit ad31e2b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/test_CiscoConfParse.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import re
3636
import os
3737

38-
sys.path.insert(0, "..")
38+
THIS_TEST_PATH = os.path.dirname(os.path.abspath(__file__))
3939

4040
from loguru import logger
4141
from passlib.hash import cisco_type7
@@ -52,37 +52,37 @@
5252

5353
def testParse_valid_filepath_01():
5454
"""Test reading a cisco ios config-file on disk (without the config keyword); ref github issue #262."""
55-
parse = CiscoConfParse("../configs/sample_01.ios")
55+
parse = CiscoConfParse(f"{THIS_TEST_PATH}/fixtures/configs/sample_01.ios")
5656
assert len(parse.ioscfg) == 450
5757

5858

5959
def testParse_valid_filepath_02():
6060
"""Test reading a cisco ios config-file on disk (from filename in the config parameter); ref github issue #262."""
61-
parse = CiscoConfParse(config="../configs/sample_01.ios")
61+
parse = CiscoConfParse(config=f"{THIS_TEST_PATH}/fixtures/configs/sample_01.ios")
6262
assert len(parse.ioscfg) == 450
6363

6464

6565
def testParse_valid_filepath_03():
6666
"""Test reading an f5 config-file on disk (without the config keyword); ref github issue #262."""
67-
parse = CiscoConfParse("../configs/sample_01.f5", comment="#", syntax="junos")
67+
parse = CiscoConfParse(f"{THIS_TEST_PATH}/fixtures/configs/sample_01.f5", comment="#", syntax="junos")
6868
assert len(parse.ioscfg) == 16
6969

7070

7171
def testParse_valid_filepath_04():
7272
"""Test reading an f5 config-file on disk (from filename in the config parameter); ref github issue #262."""
73-
parse = CiscoConfParse(config="../configs/sample_01.f5", comment="#", syntax="junos")
73+
parse = CiscoConfParse(config=f"{THIS_TEST_PATH}/fixtures/configs/sample_01.f5", comment="#", syntax="junos")
7474
assert len(parse.ioscfg) == 16
7575

7676

7777
def testParse_valid_filepath_05():
7878
"""Test reading a junos config-file on disk (without the config keyword); ref github issue #262."""
79-
parse = CiscoConfParse("../configs/sample_01.junos", comment="#", syntax="junos")
79+
parse = CiscoConfParse(f"{THIS_TEST_PATH}/fixtures/configs/sample_01.junos", comment="#", syntax="junos")
8080
assert len(parse.ioscfg) == 79
8181

8282

8383
def testParse_valid_filepath_06():
8484
"""Test reading a junos config-file on disk (from filename in the config parameter); ref github issue #262."""
85-
parse = CiscoConfParse(config="../configs/sample_01.junos", comment="#", syntax="junos")
85+
parse = CiscoConfParse(config=f"{THIS_TEST_PATH}/fixtures/configs/sample_01.junos", comment="#", syntax="junos")
8686
assert len(parse.ioscfg) == 79
8787

8888

@@ -119,11 +119,11 @@ def testParse_f5_as_ios_00(parse_f01_ios):
119119
def testParse_f5_as_ios_02(parse_f02_ios_01):
120120
"""
121121
Test parsing a brace-delimited f5 config with ios syntax. Use
122-
configs/sample_02.f5 as the test config. That f5 config is pre-parsed in
122+
fixtures/configs/sample_02.f5 as the test config. That f5 config is pre-parsed in
123123
conftest.py as 'parse_f02_ios'.
124124
125125
This Config Parsing Syntax:
126-
parse_f02_ios = CiscoConfParse('configs/sample_02.f5', syntax='ios')
126+
parse_f02_ios = CiscoConfParse('fixtures/configs/sample_02.f5', syntax='ios')
127127
128128
Ensure that line numbers, parent line numbers, and config text line up
129129
correctly... important note... closing curly-braces should be assigned as
@@ -1985,7 +1985,7 @@ def testValues_HDiff_02():
19851985
)
19861986
def testValues_HDiff_10():
19871987
"""
1988-
Test parsing an f5 config with ios syntax. Use configs/sample_01.f5 as
1988+
Test parsing an f5 config with ios syntax. Use fixtures/configs/sample_01.f5 as
19891989
the test config. That f5 config is pre-parsed in conftest.py as
19901990
'parse_f01_ios'.
19911991
"""

0 commit comments

Comments
 (0)