Skip to content
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
43 changes: 43 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master", "dev", "gha" ]
pull_request:
branches: [ "master", "dev", "gha" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with unittest
run: |
python3 -m unittest discover
- name: Test with pytest
run: |
pytest
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# **Diagnosticism.Python** Changes

## 0.15.1 - 24th August 2025

* Python version compatibility claims;
* Python 3.8 compatibility;
* GitHub Actions;
* badges;
* boilerplate;


## 0.15.0 - 13th August 2025

* added `asynctracefunc` decorator;
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

Diagnosticism library, for Python

<!--
[![CircleCI](https://circleci.com/gh/google/diagnosticism.svg?style=svg)](https://circleci.com/gh/google/diagnosticism)
-->
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![PyPI version](https://badge.fury.io/py/diagnosticism.svg)](https://badge.fury.io/py/diagnosticism)
![versions](https://img.shields.io/pypi/pyversions/diagnosticism.svg)
[![Python](https://github.com/synesissoftware/Diagnosticism.Python/actions/workflows/python-package.yml/badge.svg)](https://github.com/synesissoftware/Diagnosticism.Python/actions/workflows/python-package.yml)
[![Last Commit](https://img.shields.io/github/last-commit/synesissoftware/Diagnosticism.Python)](https://github.com/synesissoftware/Diagnosticism.Python/commits/master)


## Table of Contents <!-- omit from toc -->
Expand Down
12 changes: 9 additions & 3 deletions diagnosticism/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
__license__ = 'BSD-3-Clause'
__maintainer__ = 'Matt Wilson'
__status__ = 'Beta'
__version__ = '0.15.0'
__version__ = '0.15.1'

import sys

from .contingent_reporting import (
abort,
Expand Down Expand Up @@ -39,9 +41,13 @@
is_tracing_enabled,
line,
trace,
tracefunc,
asynctracefunc,
)
if sys.version_info[:2] >= (3, 9):
from .tracing import (
tracefunc,
asynctracefunc,
)

from .warning import warn


Expand Down
2 changes: 1 addition & 1 deletion diagnosticism/severity.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
_INTEGER_TYPES = (int, )
else:

_INTEGER_TYPES = (int, long, )
_INTEGER_TYPES = (int, long, ) # noqa: F821


def _parse_verbosity(
Expand Down
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
setuptools.setup(

name='diagnosticism',
version='0.15.0',
version='0.15.1',

author='Matt Wilson',
author_email='matthew@synesis.com.au',
Expand All @@ -17,6 +17,12 @@
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"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",
"Programming Language :: Python :: 3.13",
],
description='Basic diagnostic facilities, for Python',
keywords='Diagnostic Diagnostics Logging Trace Tracing Stopwatch',
Expand Down
39 changes: 25 additions & 14 deletions tests/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
from diagnosticism.tracing import (
enable_tracing,
trace,
tracefunc,
)
import sys
if sys.version_info[:2] >= (3, 9):
from diagnosticism.tracing import (
tracefunc,
)

import unittest
from unittest.mock import patch
Expand All @@ -28,11 +32,17 @@ def f1():

return "f1-result"

@tracefunc
def f2():
if sys.version_info[:2] >= (3, 9):

return "f2-result"
@tracefunc
def f2():

return "f2-result"
else:

def f2():

pass

class Trace_tester(unittest.TestCase):

Expand Down Expand Up @@ -89,20 +99,21 @@ def test__trace__WITH_TRACING_ENABLED(self):
enable_tracing(tracing_enabled)


def test__tracefunc__WITH_TRACING_ENABLED(self):
if sys.version_info[:2] >= (3, 9):
def test__tracefunc__WITH_TRACING_ENABLED(self):

with patch('sys.stderr', new=StringIO()) as fake_stderr:
with patch('sys.stderr', new=StringIO()) as fake_stderr:

tracing_enabled = True if enable_tracing(True) else False
tracing_enabled = True if enable_tracing(True) else False

try:
try:

set_program_name('myprog3')
set_program_name('myprog3')

r = f2()
r = f2()

self.assertEqual('f2-result', r)
self.assertRegex(fake_stderr.getvalue(), r'^\[myprog3, \d+, \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}, .*TRACE.*\]: f2()')
finally:
self.assertEqual('f2-result', r)
self.assertRegex(fake_stderr.getvalue(), r'^\[myprog3, \d+, \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}, .*TRACE.*\]: f2()')
finally:

enable_tracing(tracing_enabled)
enable_tracing(tracing_enabled)