Skip to content

Tests: move first test to pytest #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ 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: |
export PATH=~/castxml/bin:$PATH
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)
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.