Skip to content

Commit 35f5387

Browse files
committed
Reorg test files
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent d68d368 commit 35f5387

22 files changed

+21
-18
lines changed

tests/README.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/test_gemfileparser2.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,28 @@
33
# Copyright (c) Balasankar C <balasankarc@autistici.org> and others
44
# SPDX-License-Identifier: GPL-3.0-or-later OR MIT
55

6+
import json
7+
import os
8+
69
from gemfileparser2 import GemfileParser
710

11+
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
12+
813

914
def check_gemparser_results(test_file, regen=False):
1015
"""
11-
Run GemfileParser.parse on `test_file` and check against a JSON file that
12-
contains expected results with the same name as the `test_file` with a
16+
Run GemfileParser.parse on ``test_file`` and check against a JSON file that
17+
contains expected results with the same name as the ``test_file`` with a
1318
"-expected.json" suffix appended.
1419
"""
15-
import json
16-
20+
test_file = os.path.join(TEST_DATA_DIR, test_file)
1721
gemparser = GemfileParser(test_file)
1822
dependencies = {
19-
group: [dep.to_dict() for dep in deps] for group, deps in gemparser.parse().items()
23+
group: [dep.to_dict() for dep in deps]
24+
for group, deps in gemparser.parse().items()
2025
}
2126

22-
expected_file = test_file + "-expected.json"
27+
expected_file = f"{test_file}-expected.json"
2328
if regen:
2429
with open(expected_file, "w") as o:
2530
json.dump(dependencies, o, indent=2)
@@ -31,40 +36,40 @@ def check_gemparser_results(test_file, regen=False):
3136

3237

3338
def test_source_only_gemfile():
34-
check_gemparser_results("tests/Gemfile")
39+
check_gemparser_results("gemfiles/Gemfile")
3540

3641

3742
def test_gemfile_1():
38-
check_gemparser_results("tests/Gemfile_1")
43+
check_gemparser_results("gemfiles/Gemfile_1")
3944

4045

4146
def test_gemfile_2():
42-
check_gemparser_results("tests/Gemfile_2")
47+
check_gemparser_results("gemfiles/Gemfile_2")
4348

4449

4550
def test_gemfile_3():
46-
check_gemparser_results("tests/Gemfile_3")
51+
check_gemparser_results("gemfiles/Gemfile_3")
4752

4853

4954
def test_gemfile_4():
50-
check_gemparser_results("tests/Gemfile_4")
55+
check_gemparser_results("gemfiles/Gemfile_4")
5156

5257

5358
def test_gemfile_platforms():
54-
check_gemparser_results("tests/Gemfile_5")
59+
check_gemparser_results("gemfiles/Gemfile_5")
5560

5661

5762
def test_gemspec_1():
58-
check_gemparser_results("tests/sample.gemspec")
63+
check_gemparser_results("gemspecs/sample.gemspec")
5964

6065

6166
def test_gemspec_2():
62-
check_gemparser_results("tests/address_standardization.gemspec")
67+
check_gemparser_results("gemspecs/address_standardization.gemspec")
6368

6469

6570
def test_gemspec_3():
66-
check_gemparser_results("tests/arel.gemspec")
71+
check_gemparser_results("gemspecs/arel.gemspec")
6772

6873

6974
def test_gemspec_4():
70-
check_gemparser_results("tests/logstash-mixin-ecs_compatibility_support.gemspec")
75+
check_gemparser_results("gemspecs/logstash-mixin-ecs_compatibility_support.gemspec")

0 commit comments

Comments
 (0)