Skip to content

Commit d1309a4

Browse files
committed
tests/test_fru.py: use this_file_path
Get the path to the test file only onetime and use it later on. Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
1 parent 7f6abde commit d1309a4

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

tests/test_fru.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
get_fru_inventory_from_file)
88

99

10+
this_file_path = os.path.dirname(os.path.abspath(__file__))
11+
1012
def test_frudata_object():
1113
fru_field = FruData((0, 1, 2, 3))
1214
assert fru_field.data[0] == 0
@@ -26,15 +28,13 @@ def test_commonheader_object():
2628

2729

2830
def test_fru_inventory_from_file():
29-
path = os.path.dirname(os.path.abspath(__file__))
30-
fru_file = os.path.join(path, 'fru_bin/kontron_am4010.bin')
31+
fru_file = os.path.join(this_file_path, 'fru_bin/kontron_am4010.bin')
3132
fru = get_fru_inventory_from_file(fru_file)
3233
assert fru.chassis_info_area is None
3334

3435

3536
def test_board_area():
36-
path = os.path.dirname(os.path.abspath(__file__))
37-
fru_file = os.path.join(path, 'fru_bin/kontron_am4010.bin')
37+
fru_file = os.path.join(this_file_path, 'fru_bin/kontron_am4010.bin')
3838
fru = get_fru_inventory_from_file(fru_file)
3939

4040
board_area = fru.board_info_area
@@ -45,8 +45,7 @@ def test_board_area():
4545

4646

4747
def test_product_area():
48-
path = os.path.dirname(os.path.abspath(__file__))
49-
fru_file = os.path.join(path, 'fru_bin/kontron_am4010.bin')
48+
fru_file = os.path.join(this_file_path, 'fru_bin/kontron_am4010.bin')
5049
fru = get_fru_inventory_from_file(fru_file)
5150

5251
product_area = fru.product_info_area
@@ -57,8 +56,7 @@ def test_product_area():
5756

5857

5958
def test_multirecord_with_power_module_capability_record():
60-
path = os.path.dirname(os.path.abspath(__file__))
61-
fru_file = os.path.join(path, 'fru_bin/vadatech_utc017.bin')
59+
fru_file = os.path.join(this_file_path, 'fru_bin/vadatech_utc017.bin')
6260
fru = get_fru_inventory_from_file(fru_file)
6361
assert len(fru.multirecord_area.records) == 1
6462
record = fru.multirecord_area.records[0]

0 commit comments

Comments
 (0)