Skip to content

Commit

Permalink
Merge pull request #48 from melexis/fix-deprecation-warnings
Browse files Browse the repository at this point in the history
Move modules from namespace 'mlx' to 'mlx/xunit2rst'
  • Loading branch information
JasperCraeghs authored Jan 12, 2024
2 parents 309f03c + cec9378 commit b41dcc9
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 90 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -59,15 +59,15 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install twine build
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ wheels/
.installed.cfg
*.egg
MANIFEST
mlx/__xunit2rst_version__.py
mlx/xunit2rst/__version__.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ recursive-include doc *.yml
recursive-include doc Makefile
include tox.ini
recursive-include mlx *.mako
recursive-include mlx *.css

exclude mlx/__xunit2rst_version__.py
exclude mlx/xunit2rst/__version__.py
exclude .pylintrc
exclude doc/source/generated/*

recursive-include tests *.py
recursive-include tests *.rst
recursive-include tests *.xml
exclude tests/test_out/*

include doc/source/_static/xunit2rst.css
29 changes: 16 additions & 13 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
import mlx.traceability
from pkg_resources import get_distribution
from importlib.metadata import distribution
from pathlib import Path

import mlx.traceability
import mlx.xunit2rst
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -21,16 +23,16 @@
authors = ['Bavo Van Achte', 'Jasper Craeghs']

# The full version, including alpha/beta/rc tags
release = get_distribution('mlx.xunit2rst').version
release = distribution('mlx.xunit2rst').version
version = '.'.join(release.split('.')[:2])

latex_documents = [
('index', 'xunit2rst.tex', 'Script to convert .robot files to .rst files with traceable items',
('index', 'xunit2rst.tex', 'Script to convert xUnit files to .rst files with traceable items',
' \\and '.join(authors), 'manual', True),
]

man_pages = [
('index', 'xunit2rst', 'Script to convert .robot files to .rst files with traceable items',
('index', 'xunit2rst', 'Script to convert xUnit files to .rst files with traceable items',
authors, 1)
]

Expand All @@ -41,7 +43,7 @@
# dir menu entry, description, category)
texinfo_documents = [
('index', 'xunit2rst', 'xunit2rst conversion script', '@*'.join(authors), 'xunit2rst',
'Script to convert .robot files to .rst files with traceable items.', 'Miscellaneous'),
'Script to convert xUnit files to .rst files with traceable items.', 'Miscellaneous'),
]

# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -114,17 +116,18 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = [os.path.join(os.path.dirname(mlx.traceability.__file__), 'assets'),
'_static']

# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_css_files = [
'xunit2rst.css',
html_static_path = [
str(Path(mlx.traceability.__file__).parent / 'assets'),
str(Path(mlx.xunit2rst.__file__).parent / 'assets'),
]

traceability_render_relationship_per_item = True


def setup(app):
# Color Test Results
app.add_css_file('xunit2rst.css')

# To demo --only input argument
if os.environ.get('LAYER', 'FLASH') == 'FLASH':
tags.add('FLASH')
1 change: 0 additions & 1 deletion mlx/__init__.py

This file was deleted.

Empty file added mlx/xunit2rst/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions mlx/xunit2rst.py → mlx/xunit2rst/xunit2rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import logging
import xml.etree.ElementTree as ET
from collections import namedtuple
from importlib.metadata import distribution, PackageNotFoundError
from pathlib import Path
from textwrap import indent

from mako.exceptions import RichTraceback
from mako.template import Template
from pkg_resources import DistributionNotFound, require
from ruamel.yaml import YAML

TraceableInfo = namedtuple("TraceableInfo", ['matrix_prefix', 'type', 'header_prefix'])
Expand Down Expand Up @@ -229,8 +229,8 @@ def verify_prefix_set(prefix_set, prefix, type_):
def create_parser():
""" Creates and returns the ArgumentParser instance to be used """
try:
version = require('mlx.xunit2rst')[0].version
except DistributionNotFound:
version = distribution('mlx.xunitrst').version
except PackageNotFoundError:
version = '0.0.0.dev'
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-i', '--input',
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools-scm>=6.0.0", "setuptools>=69.0.3"]
build-backend = "setuptools.build_meta"
22 changes: 12 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from setuptools import setup, find_packages
from setuptools import find_namespace_packages, setup

requires = [
'mako',
Expand All @@ -8,9 +8,8 @@
setup(
name='mlx.xunit2rst',
use_scm_version={
'write_to': 'mlx/__xunit2rst_version__.py'
'write_to': 'mlx/xunit2rst/__version__.py'
},
setup_requires=['setuptools-scm>=6.0.0'],
url='https://github.com/melexis/xunit2rst',
license='Apache License Version 2.0',
author='JasperCraeghs',
Expand All @@ -27,27 +26,30 @@
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Documentation',
'Topic :: Documentation :: Sphinx',
'Topic :: Utilities',
],
platforms='any',
packages=find_packages(exclude=['tests', 'doc']),
package_data={'mlx.xunit2rst': ['mlx/*.mako']},
packages=find_namespace_packages(where='.'),
package_dir={"": "."},
package_data={
'mlx.xunit2rst': ['*.mako'],
'mlx.xunit2rst.assets': ['*.css']
},
include_package_data=True,
install_requires=requires,
python_requires='>=3.7',
namespace_packages=['mlx'],
python_requires='>=3.8',
keywords=['xUnit', 'JUnit', 'XML', 'reStructuredText', 'sphinx', 'rst', 'testing', 'traceability', 'documentation'],
entry_points={
'console_scripts': [
'mlx.xunit2rst = mlx.xunit2rst:main',
'xunit2rst = mlx.xunit2rst:main',
'mlx.xunit2rst = mlx.xunit2rst.xunit2rst:main',
'xunit2rst = mlx.xunit2rst.xunit2rst:main',
]
},
)
6 changes: 3 additions & 3 deletions tests/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import unittest
from pathlib import Path

from mlx.xunit2rst import create_parser, generate_xunit_to_rst
from mlx.xunit2rst import xunit2rst as dut

TOP_DIR = Path(__file__).parents[1]
TEST_OUT_DIR = Path(__file__).parent / 'test_out'
Expand All @@ -18,7 +18,7 @@
def xunit2rst_check(input_xml, output_rst, itemize_suites=False, prefix='', trim=False, type_=None, failures=False,
log_file='', add_links=False):
''' Helper function for testing whether mlx.xunit2rst produces the expected output '''
arg_parser = create_parser()
arg_parser = dut.create_parser()
command = ['-i', input_xml, '-o', output_rst]
if itemize_suites:
command.append('--itemize-suites')
Expand All @@ -37,7 +37,7 @@ def xunit2rst_check(input_xml, output_rst, itemize_suites=False, prefix='', trim
print(command)
args = arg_parser.parse_args(command)

generate_xunit_to_rst(
dut.generate_xunit_to_rst(
args.input_file,
args.rst_output_file,
args.itemize_suites,
Expand Down
6 changes: 3 additions & 3 deletions tests/mako_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path
from unittest import TestCase

from mlx.xunit2rst import ITEST, render_template
from mlx.xunit2rst import xunit2rst as dut

TEST_OUT_DIR = Path(__file__).parent / 'test_out'

Expand All @@ -16,13 +16,13 @@ def test_mako_error_handling(self):
variable '''
kwargs = {
'report_name': 'my_report',
'info': ITEST,
'info': dut.ITEST,
'prefix': 'MAKO_TEST-',
}
test_case = TestCase()
with test_case.assertLogs() as log_cm:
with self.assertRaises(TypeError):
render_template((TEST_OUT_DIR / 'never_created_file.rst'), **kwargs)
dut.render_template((TEST_OUT_DIR / 'never_created_file.rst'), **kwargs)
test_case.assertIn('Exception raised in Mako template, which will be re-raised after logging line info:',
log_cm.output[0])
test_case.assertIn('File ', log_cm.output[-1])
Expand Down
Loading

0 comments on commit b41dcc9

Please sign in to comment.