Skip to content

Commit

Permalink
Merge pull request #203 from scalative/mnt/modernize-code
Browse files Browse the repository at this point in the history
MNT/modernize code
  • Loading branch information
itziakos authored Sep 23, 2024
2 parents 9f37210 + 866a865 commit e9c45e8
Show file tree
Hide file tree
Showing 54 changed files with 107 additions and 253 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]
os: [windows-latest, ubuntu-latest, macos-latest]
exclude:
- python-version: "3.7"
os: macos-latest
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 0 additions & 2 deletions haas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

import logging

__version__ = '0.10.0.dev1'
Expand Down
12 changes: 6 additions & 6 deletions haas/error_holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright the CPython developers and contributors.


class ErrorHolder(object):
class ErrorHolder:
"""
Placeholder for a TestCase inside a result. As far as a TestResult
is concerned, this looks exactly like a unit test. Used to insert
Expand All @@ -21,15 +21,11 @@ def __init__(self, description):
def id(self):
return self.description

@property
def _testMethodName(self):
return self.description

def shortDescription(self):
return None

def __repr__(self):
return "<ErrorHolder description=%r>" % (self.description,)
return f"<ErrorHolder description={self.description!r}>"

def __str__(self):
return self.id()
Expand All @@ -44,3 +40,7 @@ def __call__(self, result):

def countTestCases(self):
return 0

@property
def _testMethodName(self):
return self.description
1 change: 0 additions & 1 deletion haas/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals


class HaasException(Exception):
Expand Down
4 changes: 1 addition & 3 deletions haas/haas_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

import argparse
import os

Expand Down Expand Up @@ -64,7 +62,7 @@ def _add_log_level_option(parser):
help='Log level for haas logging')


class HaasApplication(object):
class HaasApplication:
"""Main haas application entry-point.
"""
Expand Down
4 changes: 1 addition & 3 deletions haas/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

import unittest

from .suite import TestSuite


class Loader(object):
class Loader:
"""Load individual test cases from modules and wrap them in the
:class:`~haas.suite.Suite` container.
Expand Down
2 changes: 0 additions & 2 deletions haas/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals # pragma: no cover

import sys # pragma: no cover

from .haas_application import HaasApplication # pragma: no cover
Expand Down
3 changes: 1 addition & 2 deletions haas/module_import_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals


class ModuleImportError(object):
class ModuleImportError:
"""A base class for generated ModuleImportError placeholder test cases.
"""
3 changes: 1 addition & 2 deletions haas/plugin_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals


class PluginContext(object):
class PluginContext:
"""Handles correct setup and teardown of multiple plugins.
"""
Expand Down
11 changes: 2 additions & 9 deletions haas/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,17 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

import sys
import logging
from collections import OrderedDict

from stevedore.extension import ExtensionManager

from .utils import uncamelcase

if sys.version_info < (2, 7): # pragma: no cover
from ordereddict import OrderedDict
else: # pragma: no cover
from collections import OrderedDict

logger = logging.getLogger(__name__)


class PluginManager(object):
class PluginManager:

ENVIRONMENT_HOOK = 'haas.hooks.environment'

Expand Down
1 change: 0 additions & 1 deletion haas/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals
2 changes: 0 additions & 2 deletions haas/plugins/base_hook_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

from .i_hook_plugin import IHookPlugin


Expand Down
2 changes: 0 additions & 2 deletions haas/plugins/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

import coverage

from .base_hook_plugin import BaseHookPlugin
Expand Down
4 changes: 1 addition & 3 deletions haas/plugins/discoverer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

from fnmatch import fnmatch
from importlib import import_module
from os import getcwd
Expand All @@ -14,11 +12,11 @@
import os
import sys
import traceback
import unittest

from haas.exceptions import DotInModuleNameError
from haas.module_import_error import ModuleImportError
from haas.suite import find_test_cases
from haas.testing import unittest
from .i_discoverer_plugin import IDiscovererPlugin

logger = logging.getLogger(__name__)
Expand Down
8 changes: 2 additions & 6 deletions haas/plugins/i_discoverer_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals
from abc import ABC, abstractmethod, abstractclassmethod

from abc import ABCMeta, abstractmethod

from haas.utils import abstractclassmethod


class IDiscovererPlugin(object, metaclass=ABCMeta):
class IDiscovererPlugin(ABC):

@abstractclassmethod
def from_args(cls, args, arg_prefix, loader):
Expand Down
10 changes: 3 additions & 7 deletions haas/plugins/i_hook_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

import abc

from haas.utils import abstractclassmethod


class IHookPlugin(object, metaclass=abc.ABCMeta):
class IHookPlugin(abc.ABC):

@abc.abstractmethod
def setup(self): # pragma: no cover
Expand All @@ -21,10 +17,10 @@ def setup(self): # pragma: no cover
def teardown(self): # pragma: no cover
pass

@abstractclassmethod
@abc.abstractclassmethod
def add_parser_arguments(cls, parser, name, option_prefix, dest_prefix):
pass

@abstractclassmethod
@abc.abstractclassmethod
def from_args(cls, args, dest_prefix):
pass
8 changes: 2 additions & 6 deletions haas/plugins/i_result_handler_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals
from abc import ABC, abstractmethod, abstractclassmethod

from abc import ABCMeta, abstractmethod

from haas.utils import abstractclassmethod


class IResultHandlerPlugin(object, metaclass=ABCMeta):
class IResultHandlerPlugin(ABC):

@abstractclassmethod
def from_args(cls, args, name, dest_prefix, test_count):
Expand Down
8 changes: 2 additions & 6 deletions haas/plugins/i_runner_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals
from abc import ABC, abstractclassmethod

import abc

from haas.utils import abstractclassmethod


class IRunnerPlugin(object, metaclass=abc.ABCMeta):
class IRunnerPlugin(ABC):

@abstractclassmethod
def from_args(cls, args, arg_prefix):
Expand Down
6 changes: 6 additions & 0 deletions haas/plugins/parallel_runner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2014 Simon Jagoe
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from importlib import import_module
from multiprocessing import Pool
import time
Expand Down
4 changes: 1 addition & 3 deletions haas/plugins/result_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

import statistics
import sys
import time
Expand All @@ -22,7 +20,7 @@ def get_test_description(test, descriptions=True):
return str(test)


class _WritelnDecorator(object):
class _WritelnDecorator:
"""Used to decorate file-like objects with a handy 'writeln' method"""
def __init__(self, stream):
self.stream = stream
Expand Down
2 changes: 0 additions & 2 deletions haas/plugins/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

from .i_runner_plugin import IRunnerPlugin
import warnings

Expand Down
1 change: 0 additions & 1 deletion haas/plugins/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals
7 changes: 2 additions & 5 deletions haas/plugins/tests/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license. See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals
from unittest import mock
import unittest

try:
import coverage
Expand All @@ -14,10 +15,6 @@
Coverage = None


from haas.testing import unittest
from haas.tests.compat import mock


@unittest.skipIf(coverage is None, 'Coverage is not installed')
class TestCoverage(unittest.TestCase):

Expand Down
Loading

0 comments on commit e9c45e8

Please sign in to comment.