Skip to content

Commit

Permalink
take logger in use (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
jupe authored Sep 2, 2024
1 parent 758b19b commit eac21a6
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 77 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ on:
pull_request:
paths-ignore:
- '**.md'

jobs:
test:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9']
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install deps
Expand All @@ -34,7 +36,7 @@ jobs:
# missing tests, sorry
#- name: coveralls
# if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
# env:
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: coveralls
- name: pylint
Expand All @@ -45,12 +47,12 @@ jobs:
run: |
pytest --opentmi localhost:3000 --opentmi_token 123 --metadata foo bar --metadata DUT_SERIAL_NUMBER 123 --metadata DUT_MODEL S5 --metadata DUT_VENDOR samsang example.py
- name: Archive artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: artifacts
name: artifacts-${{ runner.os }}-${{ matrix.python-version }}
path: |
htmlcov
junit
htmlcov/*
junit/*
- name: install rel deps
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
run: |
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/codeball.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017
Copyright (c) 2024

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
40 changes: 1 addition & 39 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,useless-object-inheritance
disable=logging-fstring-interpolation

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -233,12 +233,6 @@ max-line-length=120
# Maximum number of lines in a module
max-module-lines=1000

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,dict-separator

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
Expand All @@ -250,70 +244,41 @@ single-line-if-stmt=no

[BASIC]

# Naming hint for argument names
argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Regular expression matching correct argument names
argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Naming hint for attribute names
attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Regular expression matching correct attribute names
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata

# Naming hint for class attribute names
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Regular expression matching correct class attribute names
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Naming hint for class names
class-name-hint=[A-Z_][a-zA-Z0-9]+$

# Regular expression matching correct class names
class-rgx=[A-Z_][a-zA-Z0-9]+$

# Naming hint for constant names
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$

# Regular expression matching correct constant names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$

# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1

# Naming hint for function names
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Regular expression matching correct function names
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Good variable names which should always be accepted, separated by a comma
good-names=i,j,k,ex,Run,_

# Include a hint for the correct naming format with invalid-name
include-naming-hint=no

# Naming hint for inline iteration names
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$

# Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$

# Naming hint for method names
method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Regular expression matching correct method names
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Naming hint for module names
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

# Regular expression matching correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

Expand All @@ -329,9 +294,6 @@ no-docstring-rgx=^_
# to this list to register other decorators that produce valid properties.
property-classes=abc.abstractproperty

# Naming hint for variable names
variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Regular expression matching correct variable names
variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

Expand Down
16 changes: 12 additions & 4 deletions pytest_opentmi/OpenTmiReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import datetime
import uuid
import inspect
import logging
from multiprocessing.dummy import Pool as ThreadPool
# 3rd party modules
from opentmi_client import OpenTmiClient, Result
from opentmi_client.api import Dut, File, Provider, Testcase
# app modules
from . import __pytest_info__

logger = logging.getLogger(__name__)


# pylint: disable=too-many-instance-attributes
class OpenTmiReport:
Expand Down Expand Up @@ -283,7 +286,8 @@ def _link_session(self, session, result): # pylint: disable=unused-argument
def _upload_report(self, result: Result):
try:
data = self._client.post_result(result)
print(data)
logger.info(f"Uploaded {result.tcid} successfully, id: {data['id']}")
logger.debug(f"Uploaded {result.tcid} successfully, data: {data}")
self._uploaded_success += 1
except Exception: # pylint: disable=broad-except
self._uploaded_failed += 1
Expand All @@ -298,8 +302,11 @@ def _upload_reports(self, session):
[self._link_session(session, result) for result in self.results]

# pylint: disable=expression-not-assigned
[print(result.data) for result in self.results]
[print(test) for test in self.tests]
logger.info(f'Test results to be upload ({len(self.results)})')
[logger.debug(result.data) for result in self.results]

logger.info(f'Test cases to be upload ({len(self.tests)})')
[logger.debug(test) for test in self.tests]

token = self.config.getoption("opentmi_token")
pool = ThreadPool(10)
Expand All @@ -310,8 +317,9 @@ def _upload_reports(self, session):
pool.map(self._upload_report, self.results)
pool.close()
pool.join()
logger.info('All results uploaded successfully')
except Exception as error: # pylint: disable=broad-except
print(error)
logger.error(error)

@staticmethod
def _get_test_key(item):
Expand Down
4 changes: 4 additions & 0 deletions pytest_opentmi/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
pytest plugin
"""
import os
import logging
# app modules
from . import __version__
from .OpenTmiReport import OpenTmiReport

logger = logging.getLogger(__name__)


# pylint: disable=unused-argument
def pytest_report_header(config):
Expand Down Expand Up @@ -59,6 +62,7 @@ def pytest_configure(config):
# prevent opening opentmi reporter on slave nodes (xdist)
config._opentmi = OpenTmiReport(config) # pylint: disable=protected-access
config.pluginmanager.register(config._opentmi) # pylint: disable=protected-access
logger.debug(f'Opentmi reporter enabled: {host}')


def pytest_unconfigure(config):
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# Similar to `install_requires` above, these must be valid existing
# projects.
extras_require={ # Optional
'dev': ['coverage', 'coveralls', 'mock', 'pylint==2.15.10', 'nose', 'pyinstaller']
'dev': ['coverage', 'coveralls', 'mock', 'pylint==2.15.10', 'pynose', 'pyinstaller']
},
license="Mozilla Public License 2.0 (MPL 2.0)",
keywords="py.test pytest opentmi report",
Expand All @@ -48,9 +48,10 @@
"Topic :: Utilities",
"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 :: Only",
],
)
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# and then run "tox" from this directory.

[tox]
envlist = py{36,37,py3}{,-ansi2html}, linting
envlist = py{38,py3}{,-ansi2html}, linting

[testenv]
setenv = PYTHONDONTWRITEBYTECODE=1
deps =
pytest-xdist
pytest-rerunfailures
pytest-mock
py{36,37,py3}-ansi2html: ansi2html
py{38,py3}-ansi2html: ansi2html
commands = pytest -v -r a {posargs}

[testenv:linting]
Expand Down

0 comments on commit eac21a6

Please sign in to comment.