Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
elliptical committed Feb 16, 2021
2 parents 78aef83 + efdac74 commit 238a864
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 45 deletions.
3 changes: 0 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[MESSAGES CONTROL]
disable = locally-disabled

[FORMAT]
max-line-length = 100
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
dist: xenial
dist: bionic
language: python
python: 3.7
python: 3.9

addons:
apt:
sources:
- deadsnakes
packages:
- python3.5
- python3.6
- python3.7
- python3.8

install:
- pip install tox
Expand Down
22 changes: 18 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.0] - 2021-02-15
### Added
- `Python 3.8` is now supported.
- `Python 3.9` is now supported.

### Removed
- `Python 3.5` is no longer supported.

### Fixed
- `python path/setup.py install` no longer throws an exception trying to
locate the package's `__init__.py` file.

## [1.0.2] - 2019-02-24
### Changed
- The packaged version of `README.md` no longer includes the badges row.
Expand All @@ -21,10 +33,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Removed
- `Python 3.4` is no longer supported.

## 0.1.0 - 2017-05-07
## [0.1.0] - 2017-05-07
- Initial release.

[Unreleased]: https://github.com/elliptical/tcm/compare/1.0.2...HEAD
[Unreleased]: https://github.com/elliptical/tcm/compare/2.0.0...HEAD
[2.0.0]: https://github.com/elliptical/tcm/compare/1.0.2...2.0.0
[1.0.2]: https://github.com/elliptical/tcm/compare/1.0.1...1.0.2
[1.0.1]: https://github.com/elliptical/tcm/compare/1.0.0...1.0.1
[1.0.0]: https://github.com/elliptical/tcm/compare/0.1.0...1.0.0
[0.1.0]: https://github.com/elliptical/tcm/releases/tag/0.1.0
File renamed without changes.
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include CHANGELOG.md
include LICENSE.md
include README.md
include LICENSE
include test/__init__.py
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![version](https://img.shields.io/badge/version-1.0.2-blue.svg)](./CHANGELOG.md)
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md)
[![Build Status](https://travis-ci.org/elliptical/tcm.svg?branch=develop)](https://travis-ci.org/elliptical/tcm)
[![version](https://img.shields.io/badge/version-2.0.0-blue.svg)](./CHANGELOG.md)
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
[![Build Status](https://travis-ci.com/elliptical/tcm.svg)](https://travis-ci.com/elliptical/tcm)
[![Coverage Status](https://coveralls.io/repos/github/elliptical/tcm/badge.svg?branch=develop)](https://coveralls.io/github/elliptical/tcm?branch=develop)

# tcm (Test Case Meta)
Expand Down
27 changes: 16 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""


import os
from os import path
import re
import sys

Expand All @@ -14,37 +14,43 @@
PACKAGE_NAME = 'tcm'


if sys.version_info < (3, 5):
raise RuntimeError('{} requires Python 3.5 or higher'.format(PACKAGE_NAME))
if sys.version_info < (3, 6):
raise RuntimeError(f'{PACKAGE_NAME} requires Python 3.6 or higher')


def get_readme():
"""Return the contents of the package's README.md file excluding the badges row."""
with open('README.md') as readme_file:
with open_text_file('README.md') as readme_file:
text = readme_file.read()
h1_pos = text.index('\n#') + 1
return text[h1_pos:]


def get_version():
"""Return the version string from the package's __init__.py file."""
with open(os.path.join(PACKAGE_NAME, '__init__.py')) as version_file:
with open_text_file(PACKAGE_NAME, '__init__.py') as version_file:
version_source = version_file.read()
version_match = re.search(r"^__version__ = '([^']*)'", version_source, re.MULTILINE)
if not version_match:
raise RuntimeError('Could not find the version string.')
return version_match.group(1)


def open_text_file(*path_segments):
"""Open the specified UTF-8 encoded file relative to setup.py location."""
my_dir = path.abspath(path.dirname(__file__))
return open(path.join(my_dir, *path_segments), encoding='utf-8')


VERSION = get_version()


setup(
name=PACKAGE_NAME,
author='Andrei Boulgakov',
author_email='andrei.boulgakov@outlook.com',
url='https://github.com/elliptical/{}'.format(PACKAGE_NAME),
download_url='https://github.com/elliptical/{}/archive/{}.tar.gz'.format(PACKAGE_NAME, VERSION),
url=f'https://github.com/elliptical/{PACKAGE_NAME}',
download_url=f'https://github.com/elliptical/{PACKAGE_NAME}/archive/{VERSION}.tar.gz',
license='MIT',
platforms='All',
description='Metaclass based runtime generator of the test methods',
Expand All @@ -58,19 +64,18 @@ def get_version():
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Software Development :: Testing',
],
keywords=[
'python',
'python3',
'unittest',
'metaclass',
],
python_requires='>=3.5',
python_requires='>=3.6',
packages=[PACKAGE_NAME],
zip_safe=True,
)
2 changes: 1 addition & 1 deletion tcm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""This package provides a framework for generating test methods at runtime."""


__version__ = '1.0.2'
__version__ = '2.0.0'


import unittest
Expand Down
7 changes: 2 additions & 5 deletions tcm/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def __call__(self, func):
if not callable(func):
raise DecoratorException('The object must be callable')
if not func.__name__.startswith(TEST_METHOD_PREFIX):
raise DecoratorException(
'The object name must start with "{}"'.format(TEST_METHOD_PREFIX))
raise DecoratorException(f'The object name must start with "{TEST_METHOD_PREFIX}"')

try:
attr = getattr(func, ATTR_NAME)
Expand All @@ -37,9 +36,7 @@ def __call__(self, func):
else:
if isinstance(attr, _CapturedArguments):
raise DecoratorException('Cannot decorate the same object more than once')
else:
raise DecoratorException(
'The object already has the "{}" attribute'.format(ATTR_NAME))
raise DecoratorException(f'The object already has the "{ATTR_NAME}" attribute')

return func

Expand Down
8 changes: 4 additions & 4 deletions tcm/metaclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ class TestCaseMeta(type):
"""Metaclass based runtime generator of the test methods."""

@classmethod
def __prepare__(cls, name, bases, **kwargs): # noqa: N804 pylint: disable=unused-argument
def __prepare__(cls, name, bases, **kwargs): # pylint: disable=unused-argument
"""Use ordered mapping for the namespace regardless of the Python version."""
# Note: absent the __prepare__() method, Python 3.6 would use an ordered
# mapping while prior versions would stick with a regular dict().
return OrderedDict()

def __new__(cls, name, bases, mapping): # noqa: N804
def __new__(cls, name, bases, mapping):
"""Create the class after expanding the original mapping."""
new_mapping = dict()
for key, value in _expanded_mapping(mapping):
if key in new_mapping:
existing = _get_starting_line_number(new_mapping[key])
current = _get_starting_line_number(value)
raise MetaclassException(
'Duplicate "{}" attribute at lines {} and {}'.format(key, existing, current))
f'Duplicate "{key}" attribute at lines {existing} and {current}')
new_mapping[key] = value
return super().__new__(cls, name, bases, new_mapping)

Expand Down Expand Up @@ -89,7 +89,7 @@ def _wrapper(self):
def _wrapper(self):
return func(self, **arg)
else:
raise MetaclassException('Invalid test arg: {!r}'.format(arg))
raise MetaclassException(f'Invalid test arg: {arg!r}')

functools.update_wrapper(_wrapper, func)

Expand Down
8 changes: 2 additions & 6 deletions test/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
[REPORTS]
reports = no

[MESSAGES CONTROL]
disable = missing-docstring,locally-disabled
disable = missing-docstring

[BASIC]
good-names=x,y,z,cm
method-rgx = ([a-z_][a-z0-9_]{2,30}|test_[a-z0-9_]{1,70})$
good-names = x,y,z,cm

[FORMAT]
max-line-length = 100
2 changes: 1 addition & 1 deletion test/test_metaclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_1(self):
MetaclassTestCase.test_duplicate_test_method_name_will_raise)
self.assertEqual(
cm.exception.args[0],
'Duplicate "test_1" attribute at lines {} and {}'.format(base + 3, base + 7))
f'Duplicate "test_1" attribute at lines {base + 3} and {base + 7}')

# Make sure _SpoiledTestCase does not exist.
self.assertSetEqual(set(locals()), {'self', 'cm', '_source', 'base'})
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 2.6.0
envlist = py3{5,6,7}, flake8, pylint, coverage
envlist = py3{6,7,8,9}, flake8, pylint, coverage

[testenv]
commands = {envpython} -m unittest discover {posargs} {[common]test}
Expand Down Expand Up @@ -42,7 +42,7 @@ commands =
{envpython} -m coverage report --fail-under=100

[linters-common]
python = python3.7
python = python3.9

[common]
code =
Expand Down

0 comments on commit 238a864

Please sign in to comment.