Skip to content

Commit

Permalink
Tests: move first test to pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
iMichka committed May 6, 2024
1 parent 5090a61 commit ee99a50
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 83 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ jobs:
- name: Setup castxml config
if: matrix.compiler == 'gcc' && matrix.version == '9'
run: mv unittests/configs/gcc9.cfg unittests/xml_generator.cfg;
- name: Run tests
- name: Run legacy tests
run: |
export PATH=~/castxml/bin:$PATH
coverage run -m unittests.test_all
coverage combine
coverage xml
- name: Run tests
run: pytest tests
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ test = [
"coverage",
"coveralls",
"pycodestyle",
"pytest",
]
docs = [
"sphinx",
Expand Down
61 changes: 61 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2014-2017 Insight Software Consortium.
# Copyright 2004-2009 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt

import sys
import os
import unittest
import pytest

from pygccxml import parser
from pygccxml import utils


def test_config():
"""Test config setup with wrong xml generator setups."""

# Some code to parse for the example
code = "int a;"

# Find the location of the xml generator (castxml or gccxml)
generator_path, name = utils.find_xml_generator()

# No xml generator path
config = parser.xml_generator_configuration_t(xml_generator=name)
with pytest.raises(RuntimeError):
parser.parse_string(code, config)

# Invalid path
config = parser.xml_generator_configuration_t(
xml_generator_path="wrong/path",
xml_generator=name)
with pytest.raises(RuntimeError):
parser.parse_string(code, config)

# None path
config = parser.xml_generator_configuration_t(
xml_generator_path=None,
xml_generator=name)
with pytest.raises(RuntimeError):
parser.parse_string(code, config)

# No name
config = parser.xml_generator_configuration_t(
xml_generator_path=generator_path)
with pytest.raises(RuntimeError):
parser.parse_string(code, config)

# Random name
config = parser.xml_generator_configuration_t(
xml_generator_path=generator_path,
xml_generator="not_a_generator")
with pytest.raises(RuntimeError):
parser.parse_string(code, config)

# None name
config = parser.xml_generator_configuration_t(
xml_generator_path=generator_path,
xml_generator=None)
with pytest.raises(RuntimeError):
parser.parse_string(code, config)
2 changes: 0 additions & 2 deletions unittests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
from . import test_pattern_parser
from . import test_function_pointer
from . import test_directory_cache
from . import test_config
from . import deprecation_tester
from . import test_xml_generators
from . import test_non_copyable_recursive
Expand Down Expand Up @@ -141,7 +140,6 @@
test_pattern_parser,
test_function_pointer,
test_directory_cache,
test_config,
test_utils,
test_cpp_standards,
test_va_list_tag_removal,
Expand Down
80 changes: 0 additions & 80 deletions unittests/test_config.py

This file was deleted.

0 comments on commit ee99a50

Please sign in to comment.