Skip to content

Commit

Permalink
Merge pull request #28 from jgehrcke/jp/may2023-mod
Browse files Browse the repository at this point in the history
Code refresh, add CI
  • Loading branch information
jgehrcke committed Jun 2, 2023
2 parents 712152f + 4cfbf66 commit b1597ec
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 104 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: ci

on: [push]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.10.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: install deps
run: |
pip install -r requirements-tests.txt
pip install --editable .
- name: run tests
run: pytest -vv test
6 changes: 3 additions & 3 deletions goeffel/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,9 @@ def plot_subplot(ax, column_plot_config, series, plotsettings):
# https://github.com/matplotlib/matplotlib/issues/10369
ax.set_yscale(
'symlog',
linthreshy=_linthreshy,
linscaley=0.25,
subsy=[2, 3, 4, 5, 6, 7, 8, 9]
linthresh=_linthreshy,
linscale=0.25,
subs=[2, 3, 4, 5, 6, 7, 8, 9]
)
else:
ax.set_yscale(column_plot_config['yscale'])
Expand Down
8 changes: 4 additions & 4 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest==5.0.1
pytest-cov==2.7.1
flake8==3.7.8
twine==1.13.0
pytest
pytest-cov
flake8
twine
51 changes: 24 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,40 @@


version = re.search(
r'^__version__\s*=\s*"(.*)"',
open('goeffel/goeffel.py').read(),
re.M
).group(1)
r'^__version__\s*=\s*"(.*)"', open("goeffel/goeffel.py").read(), re.M
).group(1)


with open('README.md', 'rb') as f:
long_descr = f.read().decode('utf-8')
with open("README.md", "rb") as f:
long_descr = f.read().decode("utf-8")


setup(
name='goeffel',
packages=['goeffel'],
name="goeffel",
packages=["goeffel"],
entry_points={
'console_scripts': [
'goeffel = goeffel.goeffel:main',
'goeffel-analysis = goeffel.analysis:main'
]
},
"console_scripts": [
"goeffel = goeffel.goeffel:main",
"goeffel-analysis = goeffel.analysis:main",
]
},
version=version,
description='Measures the resource utilization of a specific process over time',
description="Measures the resource utilization of a specific process over time",
long_description=long_descr,
long_description_content_type='text/markdown',
author='Dr. Jan-Philip Gehrcke',
author_email='jgehrcke@googlemail.com',
url='https://github.com/jgehrcke/goeffel',
long_description_content_type="text/markdown",
author="Dr. Jan-Philip Gehrcke",
author_email="jgehrcke@googlemail.com",
url="https://github.com/jgehrcke/goeffel",
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Operating System :: POSIX',
],
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Operating System :: POSIX",
],
# TODO(JP):pandas, matplotlib are for the analysis program only. Make it so
# that the measurement program can be pip-installed w/o requiring pandas and
# matplotlib. Use https://setuptools.readthedocs.io/en/latest/setuptools.html
# #declaring-extras-optional-features-with-their-own-dependencies
install_requires=('tables', 'psutil', 'pandas', 'matplotlib'),
)
install_requires=("tables", "psutil", "pandas", "matplotlib"),
)
54 changes: 26 additions & 28 deletions test/clitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@
log = logging.getLogger("clitest")


class CmdlineTestError(Exception):
class ClitestError(Exception):
pass


class WrongExitCode(CmdlineTestError):
class UnexpectedExitCode(ClitestError):
pass


class WrongStdout(CmdlineTestError):
class UnexpectedStdout(ClitestError):
pass


class WrongStderr(CmdlineTestError):
class UnexpectedStderr(ClitestError):
pass


class WrongFile(CmdlineTestError):
class UnexpectedFile(ClitestError):
pass


Expand Down Expand Up @@ -140,14 +140,12 @@ def clear(self):
try:
shutil.rmtree(self.rundir)
except OSError:
# Does not exist, fine.
# This typically means: does not exist.
pass

def add_file(self, name, content_bytestring):
assert isinstance(content_bytestring, binary_type)
p = os.path.join(self.rundir, name)
# 'b' mode is required on Python 3, otherwise
# TypeError: must be str, not bytes.
with open(p, "wb") as f:
f.write(content_bytestring)

Expand Down Expand Up @@ -199,7 +197,7 @@ def run(self, cmd_unicode, expect_rc=0, stdinbytes=None, log_output=True):
"Error running test subprocess. Traceback:\n%s",
traceback.format_exc()
)
raise CmdlineTestError("Error during attempt to run child.")
raise ClitestError("Error during attempt to run child.")
finally:
of.close()
ef.close()
Expand All @@ -222,17 +220,17 @@ def run(self, cmd_unicode, expect_rc=0, stdinbytes=None, log_output=True):
log.info("Cannot decode stderr: %s", e)
log.info("Test stderr repr:\n%r", self.rawerr)
if rc != expect_rc:
raise WrongExitCode("Expected %s, got %s" % (expect_rc, rc))
raise UnexpectedExitCode("Expected %s, got %s" % (expect_rc, rc))

def assert_no_stderr(self):
"""Raise `WrongStderr` if standard error is not empty."""
"""Raise `UnexpectedStderr` if standard error is not empty."""
if not self.rawerr == b"":
raise WrongStderr("stderr not empty.")
raise UnexpectedStderr("stderr not empty.")

def assert_no_stdout(self):
"""Raise `WrongStdout` if standard output is not empty."""
"""Raise `UnexpectedStdout` if standard output is not empty."""
if not self.rawout == b"":
raise WrongStdout("stdout not empty.")
raise UnexpectedStdout("stdout not empty.")

def assert_in_stdout(self, strings, encoding=None):
"""Verify that one or more strings is/are in standard output.
Expand All @@ -246,12 +244,12 @@ def assert_in_stdout(self, strings, encoding=None):
list of strings of the same type.
Raises:
`WrongStdout` in case of mismatch.
`UnexpectedStdout` in case of mismatch.
"""
out, expected = self._klazonk(self.rawout, strings, encoding)
for s in expected:
if s not in out:
raise WrongStdout("'%r' not in stdout." % s)
raise UnexpectedStdout("'%r' not in stdout." % s)

def assert_not_in_stdout(self, strings, encoding=None):
"""Verify that one or more strings is/are not in standard output.
Expand All @@ -265,12 +263,12 @@ def assert_not_in_stdout(self, strings, encoding=None):
strings of the same type.
Raises:
`WrongStdout` in case of mismatch.
`UnexpectedStdout` in case of mismatch.
"""
out, forbidden = self._klazonk(self.rawout, strings, encoding)
for s in forbidden:
if s in out:
raise WrongStdout("'%r' must not be in stdout." % s)
raise UnexpectedStdout("'%r' must not be in stdout." % s)

def assert_in_stderr(self, strings, encoding=None):
"""Verify that one or more strings is/are in standard error.
Expand All @@ -284,12 +282,12 @@ def assert_in_stderr(self, strings, encoding=None):
list of strings of the same type.
Raises:
`WrongStderr` in case of mismatch.
`UnexpectedStderr` in case of mismatch.
"""
err, expected = self._klazonk(self.rawerr, strings, encoding)
for s in expected:
if s not in err:
raise WrongStderr("'%r' not in stderr." % s)
raise UnexpectedStderr("'%r' not in stderr." % s)

def assert_not_in_stderr(self, strings, encoding=None):
"""Verify that one or more strings is/are not in standard error.
Expand All @@ -303,40 +301,40 @@ def assert_not_in_stderr(self, strings, encoding=None):
strings of the same type.
Raises:
`WrongStderr` in case of mismatch.
`UnexpectedStderr` in case of mismatch.
"""
err, forbidden = self._klazonk(self.rawerr, strings, encoding)
for s in forbidden:
if s in err:
raise WrongStderr("'%r' must not be in stderr." % s)
raise UnexpectedStderr("'%r' must not be in stderr." % s)

def assert_is_stdout(self, s, encoding=None):
"""Validate that `s` is standard output of test process.
If `s` is unicode type, decode binary stdout data before comparison.
Raises:
`WrongStdout` in case of mismatch.
`UnexpectedStdout` in case of mismatch.
"""
out = self.rawout
if isinstance(s, text_type):
out = self._decode(self.rawout, encoding)
if s != out:
raise WrongStdout("stdout is not '%r'." % s)
raise UnexpectedStdout("stdout is not '%r'." % s)

def assert_is_stderr(self, s, encoding=None):
"""Validate that `s` is standard error of test process.
If `s` is unicode type, decode binary stderr data before comparison.
Raises:
`WrongStderr` in case of mismatch.
`UnexpectedStderr` in case of mismatch.
"""
err = self.rawerr
if isinstance(s, text_type):
err = self._decode(self.rawerr, encoding)
if s != err:
raise WrongStderr("stderr is not '%r'." % s)
raise UnexpectedStderr("stderr is not '%r'." % s)

def _klazonk(self, out_or_err, string_or_stringlist, encoding):
"""Validate that `string_or_stringlist` is either a byte or unicode
Expand Down Expand Up @@ -402,10 +400,10 @@ def _paths_exist(self, p, invert=False):
testpath = os.path.join(self.rundir, path)
if not os.path.exists(testpath):
if not invert:
raise WrongFile("Path does not exist: '%s'" % path)
raise UnexpectedFile("Path does not exist: '%s'" % path)
return
if invert:
raise WrongFile("Path should not exist: '%s'" % path)
raise UnexpectedFile("Path should not exist: '%s'" % path)


def _list_string_type(o):
Expand Down

0 comments on commit b1597ec

Please sign in to comment.