Skip to content

Commit 5adf237

Browse files
committed
Tests: move first test to pytest
1 parent 5090a61 commit 5adf237

File tree

5 files changed

+67
-83
lines changed

5 files changed

+67
-83
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,13 @@ jobs:
9696
- name: Setup castxml config
9797
if: matrix.compiler == 'gcc' && matrix.version == '9'
9898
run: mv unittests/configs/gcc9.cfg unittests/xml_generator.cfg;
99-
- name: Run tests
99+
- name: Run legacy tests
100100
run: |
101101
export PATH=~/castxml/bin:$PATH
102102
coverage run -m unittests.test_all
103103
coverage combine
104104
coverage xml
105+
- name: Run tests
106+
run: |
107+
export PATH=~/castxml/bin:$PATH
108+
pytest tests

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ test = [
5555
"coverage",
5656
"coveralls",
5757
"pycodestyle",
58+
"pytest",
5859
]
5960
docs = [
6061
"sphinx",

tests/test_config.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2014-2017 Insight Software Consortium.
2+
# Copyright 2004-2009 Roman Yakovenko.
3+
# Distributed under the Boost Software License, Version 1.0.
4+
# See http://www.boost.org/LICENSE_1_0.txt
5+
6+
import sys
7+
import os
8+
import unittest
9+
import pytest
10+
11+
from pygccxml import parser
12+
from pygccxml import utils
13+
14+
15+
def test_config():
16+
"""Test config setup with wrong xml generator setups."""
17+
18+
# Some code to parse for the example
19+
code = "int a;"
20+
21+
# Find the location of the xml generator (castxml)
22+
generator_path, name = utils.find_xml_generator()
23+
24+
# No xml generator path
25+
config = parser.xml_generator_configuration_t(xml_generator=name)
26+
with pytest.raises(RuntimeError):
27+
parser.parse_string(code, config)
28+
29+
# Invalid path
30+
config = parser.xml_generator_configuration_t(
31+
xml_generator_path="wrong/path",
32+
xml_generator=name)
33+
with pytest.raises(RuntimeError):
34+
parser.parse_string(code, config)
35+
36+
# None path
37+
config = parser.xml_generator_configuration_t(
38+
xml_generator_path=None,
39+
xml_generator=name)
40+
with pytest.raises(RuntimeError):
41+
parser.parse_string(code, config)
42+
43+
# No name
44+
config = parser.xml_generator_configuration_t(
45+
xml_generator_path=generator_path)
46+
with pytest.raises(RuntimeError):
47+
parser.parse_string(code, config)
48+
49+
# Random name
50+
config = parser.xml_generator_configuration_t(
51+
xml_generator_path=generator_path,
52+
xml_generator="not_a_generator")
53+
with pytest.raises(RuntimeError):
54+
parser.parse_string(code, config)
55+
56+
# None name
57+
config = parser.xml_generator_configuration_t(
58+
xml_generator_path=generator_path,
59+
xml_generator=None)
60+
with pytest.raises(RuntimeError):
61+
parser.parse_string(code, config)

unittests/test_all.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
from . import test_pattern_parser
7373
from . import test_function_pointer
7474
from . import test_directory_cache
75-
from . import test_config
7675
from . import deprecation_tester
7776
from . import test_xml_generators
7877
from . import test_non_copyable_recursive
@@ -141,7 +140,6 @@
141140
test_pattern_parser,
142141
test_function_pointer,
143142
test_directory_cache,
144-
test_config,
145143
test_utils,
146144
test_cpp_standards,
147145
test_va_list_tag_removal,

unittests/test_config.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)