Hello community, here is the log from the commit of package python-dialite for openSUSE:Factory checked in at 2019-03-10 09:35:54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-dialite (Old) and /work/SRC/openSUSE:Factory/.python-dialite.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-dialite" Sun Mar 10 09:35:54 2019 rev:3 rq:682485 version:0.5.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-dialite/python-dialite.changes 2018-12-13 19:42:51.469136876 +0100 +++ /work/SRC/openSUSE:Factory/.python-dialite.new.28833/python-dialite.changes 2019-03-10 09:35:54.640168550 +0100 @@ -1,0 +2,7 @@ +Thu Mar 7 14:25:41 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 0.5.2: + * include tests +- Execute tests + +------------------------------------------------------------------- Old: ---- dialite-0.5.1.tar.gz New: ---- dialite-0.5.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-dialite.spec ++++++ --- /var/tmp/diff_new_pack.OeL5Fi/_old 2019-03-10 09:35:55.268168399 +0100 +++ /var/tmp/diff_new_pack.OeL5Fi/_new 2019-03-10 09:35:55.268168399 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-dialite # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,21 +17,20 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} -# Test files missing. See https://github.com/flexxui/pscript/pull/35 Name: python-dialite -Version: 0.5.1 +Version: 0.5.2 Release: 0 Summary: Python library to show simple dialogs License: BSD-2-Clause Group: Development/Languages/Python -Url: http://dialite.readthedocs.io +URL: http://dialite.readthedocs.io Source: https://files.pythonhosted.org/packages/source/d/dialite/dialite-%{version}.tar.gz +BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros Recommends: zenity BuildArch: noarch - %python_subpackages %description @@ -54,6 +53,9 @@ %python_install %python_expand %fdupes %{buildroot}%{$python_sitelib} +%check +%pytest + %files %{python_files} %doc README.md %license LICENSE ++++++ dialite-0.5.1.tar.gz -> dialite-0.5.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dialite-0.5.1/MANIFEST.in new/dialite-0.5.2/MANIFEST.in --- old/dialite-0.5.1/MANIFEST.in 2018-04-12 01:03:01.000000000 +0200 +++ new/dialite-0.5.2/MANIFEST.in 2018-11-02 13:10:01.000000000 +0100 @@ -1,5 +1,7 @@ include LICENSE README.md +recursive-include tests * + global-exclude .git* global-exclude *.pyo global-exclude *.pyc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dialite-0.5.1/PKG-INFO new/dialite-0.5.2/PKG-INFO --- old/dialite-0.5.1/PKG-INFO 2018-04-12 01:04:35.000000000 +0200 +++ new/dialite-0.5.2/PKG-INFO 2018-11-02 13:10:53.000000000 +0100 @@ -1,13 +1,12 @@ Metadata-Version: 1.1 Name: dialite -Version: 0.5.1 +Version: 0.5.2 Summary: Lightweight Python library to show simple dialogs. Home-page: http://dialite.readthedocs.io Author: Almar Klein and contributors Author-email: [email protected] License: (new) BSD Download-URL: https://pypi.python.org/pypi/dialite -Description-Content-Type: UNKNOWN Description: Dialite is a pure Python package to show dialogs. It is lightweight, cross-platform, and has no dependencies. It provides a handful of diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dialite-0.5.1/dialite/__init__.py new/dialite-0.5.2/dialite/__init__.py --- old/dialite-0.5.1/dialite/__init__.py 2018-04-12 01:03:32.000000000 +0200 +++ new/dialite-0.5.2/dialite/__init__.py 2018-11-02 13:10:12.000000000 +0100 @@ -16,7 +16,7 @@ from __future__ import absolute_import, division, print_function -__version__ = '0.5.1' # noqa +__version__ = '0.5.2' # noqa import logging import sys diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dialite-0.5.1/dialite.egg-info/PKG-INFO new/dialite-0.5.2/dialite.egg-info/PKG-INFO --- old/dialite-0.5.1/dialite.egg-info/PKG-INFO 2018-04-12 01:04:35.000000000 +0200 +++ new/dialite-0.5.2/dialite.egg-info/PKG-INFO 2018-11-02 13:10:53.000000000 +0100 @@ -1,13 +1,12 @@ Metadata-Version: 1.1 Name: dialite -Version: 0.5.1 +Version: 0.5.2 Summary: Lightweight Python library to show simple dialogs. Home-page: http://dialite.readthedocs.io Author: Almar Klein and contributors Author-email: [email protected] License: (new) BSD Download-URL: https://pypi.python.org/pypi/dialite -Description-Content-Type: UNKNOWN Description: Dialite is a pure Python package to show dialogs. It is lightweight, cross-platform, and has no dependencies. It provides a handful of diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dialite-0.5.1/dialite.egg-info/SOURCES.txt new/dialite-0.5.2/dialite.egg-info/SOURCES.txt --- old/dialite-0.5.1/dialite.egg-info/SOURCES.txt 2018-04-12 01:04:35.000000000 +0200 +++ new/dialite-0.5.2/dialite.egg-info/SOURCES.txt 2018-11-02 13:10:53.000000000 +0100 @@ -11,4 +11,6 @@ dialite.egg-info/SOURCES.txt dialite.egg-info/dependency_links.txt dialite.egg-info/top_level.txt -dialite.egg-info/zip-safe \ No newline at end of file +dialite.egg-info/zip-safe +tests/manual.py +tests/test_dialite.py \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dialite-0.5.1/tests/manual.py new/dialite-0.5.2/tests/manual.py --- old/dialite-0.5.1/tests/manual.py 1970-01-01 01:00:00.000000000 +0100 +++ new/dialite-0.5.2/tests/manual.py 2018-04-12 01:01:07.000000000 +0200 @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +""" +Manual test. Should be run on each supported platform. +""" + +import dialite + +PREFIX = 'DIALITE TEST: ' + +# Calibrate + +res = dialite.ask_yesno(PREFIX + 'yes-no', + 'Do you see two options saying "Yes and "no"? ' + 'If not this test failed before it really started ...') +assert res is True + +res = dialite.ask_yesno(PREFIX + 'yes-no', 'Make me a sandwich.') +assert res is False + +res = dialite.ask_retry(PREFIX + 'retry', 'Please let me try that again ...') +assert res is True + +res = dialite.ask_yesno(PREFIX + 'yes-no', 'Sudo make me a sandwich.') +assert res is True + +# Unicode + +res = dialite.ask_yesno(PREFIX + 'unicode', + u'Do you see "double quotes", \'single quotes\', ' + u'a euro symbol (€), pi symbol (π), an A with a roof (Â)?') +assert res is True + +# Three message boxes + +res = dialite.inform(PREFIX + 'info', 'Awesome! ' + 'We will now show three dialogs: info, warn, error. ' + 'This is the first one; an info dialog.') +assert res is None + +res = dialite.warn(PREFIX + 'warn', 'This is the second one; a warning.') +assert res is None + +res = dialite.fail(PREFIX + 'error', 'This is the third one; an error.') +assert res is None + +# Check results + +res = dialite.ask_yesno(PREFIX + 'check', + 'Did the past three boxes look something like an info, ' + 'warning, and error dialog, and have only an OK option?') +assert res is True + +# Check confirm + +res = dialite.ask_ok(PREFIX + 'confirm', + 'Great, I am going to asume all tests passed then!' + 'Press OK to continue.') +assert res is True + +res = dialite.ask_yesno(PREFIX + 'check', + 'Did you just see two buttons saying "OK" and "Cancel"?') +assert res is True + +res = dialite.ask_ok(PREFIX + 'confirm', + 'This one is a bit weird. I want you to press Cancel, ' + 'but I don\'t want you to agree and accidentally press ' + 'OK. Therefore, imagine this:\n\nWe will now proceed ' + 'with erasing all your data.') +assert res is False + +# Done + +res = dialite.inform(PREFIX + 'done', + 'This was the test, it looks like it passed!') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dialite-0.5.1/tests/test_dialite.py new/dialite-0.5.2/tests/test_dialite.py --- old/dialite-0.5.1/tests/test_dialite.py 1970-01-01 01:00:00.000000000 +0100 +++ new/dialite-0.5.2/tests/test_dialite.py 2018-02-26 15:53:14.000000000 +0100 @@ -0,0 +1,417 @@ +""" +Automatic test for dialite. There's not that much code, really, so the manual +test is way more important... +""" + +import os +import sys +import logging +import webbrowser + +from pytest import raises + +import dialite +from dialite import BaseApp, StubApp, logger +from dialite import TerminalApp, WindowsApp, LinuxApp, OSXApp + + +class _CaptureFilter: + """ To collect records in the capture_log context. + """ + def __init__(self): + self.records = [] + + def filter(self, record): + self.records.append(record.msg) #_formatter.format(record) + return False + + +class capture_log: + """ Context manager to capture log messages. Useful for testing. + Usage: + + .. code-block:: python + + with capture_log(level, match) as log: + ... + # log is a list strings (as they would have appeared in the console) + """ + + def __init__(self, level): + if isinstance(level, str): + level = getattr(logging, level.upper()) + self._level = level + self._handler = logging.Handler()#logging.root.handlers[0] + logging.root.handlers.append(self._handler) + + def __enter__(self): + self._old_level = logger.level + logger.setLevel(self._level) + self._filter = _CaptureFilter() + self._handler.addFilter(self._filter) + return self._filter.records + + def __exit__(self, type, value, traceback): + self._handler.removeFilter(self._filter) + logging.root.handlers.remove(self._handler) + logger.setLevel(self._old_level) + + +class FakeStdin(object): + + answer = 'y' + + def isatty(self): + return True + + def readline(self): + return self.answer + + +class FakeWindowsApp(WindowsApp): + + def __init__(self, *args, **kwargs): + self._messages = [] + WindowsApp.__init__(self, *args, **kwargs) + + def _message(self, type, *args, **kwargs): + self._messages.append(type) + return True + + +class FakeLinuxApp(LinuxApp): + + def __init__(self, *args, **kwargs): + self._messages = [] + LinuxApp.__init__(self, *args, **kwargs) + + def _message(self, type, *args, **kwargs): + self._messages.append(type) + return True + + +class FakeOSXApp(OSXApp): + + def __init__(self, *args, **kwargs): + self._messages = [] + OSXApp.__init__(self, *args, **kwargs) + + def _message(self, type, *args, **kwargs): + self._messages.append(type) + return True + + +class NoopApp(BaseApp): + """ An application class that does nothing. + """ + + def __init__(self): + self.res = [] + + def fail(self, title, message): + self.res.append(title) + return True + + def warn(self, title, message): + self.res.append(title) + return True + + def inform(self, title, message): + self.res.append(title) + return True + + def ask_ok(self, title, message): + self.res.append(title) + return True + + def ask_retry(self, title, message): + self.res.append(title) + return True + + def ask_yesno(self, title, message): + self.res.append(title) + return True + + +def test_check_output(): + retcode, out = dialite._base.check_output('cd', shell=True) + assert retcode == 0 + + +def test_all_backends_are_complete(): + + for cls in (StubApp, WindowsApp, LinuxApp, OSXApp): + assert issubclass(cls, BaseApp) + for name in dir(BaseApp): + if name.startswith('_'): + continue + # Check that all methods are overloaded + assert getattr(cls, name) is not getattr(BaseApp, name) + + +def test_get_app(): + + app1 = dialite._get_app() + app2 = dialite._get_app() + app3 = dialite._get_app(True) + app4 = dialite._get_app() + assert app1 is app2 + assert app3 is app4 + assert app1 is not app3 + assert type(app1) is type(app3) + + +def test_context_manager(): + + app1 = dialite._get_app() + with dialite.NoDialogs(): + app2 = dialite._get_app() + app3 = dialite._get_app() + + assert app1 is app3 + assert app1 is not app2 + assert isinstance(app2, StubApp) + + +def test_main_funcs(): + o_app = dialite._the_app + + try: + + # No args + dialite._the_app = app = NoopApp() + for func in (dialite.inform, dialite.warn, dialite.fail, + dialite.ask_ok, dialite.ask_retry, dialite.ask_yesno): + func() + # + assert app.res == ['Info', 'Warning', 'Error', + 'Confirm', 'Retry', 'Question'] + + # With args + dialite._the_app = app = NoopApp() + for func in (dialite.inform, dialite.warn, dialite.fail, + dialite.ask_ok, dialite.ask_retry, dialite.ask_yesno): + func(func.__name__, 'meh bla') + # + assert app.res == ['inform', 'warn', 'fail', + 'ask_ok', 'ask_retry', 'ask_yesno'] + + # Fails + for func in (dialite.inform, dialite.warn, dialite.fail, + dialite.ask_ok, dialite.ask_retry, dialite.ask_yesno): + with raises(TypeError): + func(3, 'meh') + with raises(TypeError): + func('meh', 3) + with raises(TypeError): + func('meh', 'bla', 'foo') # need exactly two args + + finally: + dialite._the_app = o_app + + +def test_windows(): + """ Pretend that this is Windows. """ + + o_platform = sys.platform + o_app = dialite._the_app + sys.platform = 'win32' + + try: + + app = FakeWindowsApp() + # assert app.works() + assert isinstance(app, WindowsApp) + dialite._the_app = app + + assert dialite.is_supported() + + dialite.inform() + assert len(app._messages) == 1 + + dialite.warn() + assert len(app._messages) == 2 + + dialite.fail() + assert len(app._messages) == 3 + + assert dialite.ask_ok() + assert len(app._messages) == 4 + + assert dialite.ask_retry() + assert len(app._messages) == 5 + + assert dialite.ask_yesno() + assert len(app._messages) == 6 + + finally: + sys.platform = o_platform + dialite._the_app = o_app + + +def test_linux(): + """ Pretend that this is Linux. """ + + o_platform = sys.platform + o_app = dialite._the_app + sys.platform = 'linux' + + try: + + app = FakeLinuxApp() + # assert app.works() + assert isinstance(app, LinuxApp) + dialite._the_app = app + + assert dialite.is_supported() + + dialite.inform() + assert len(app._messages) == 1 and 'info' in app._messages[-1] + + dialite.warn() + assert len(app._messages) == 2 and 'warn' in app._messages[-1] + + dialite.fail() + assert len(app._messages) == 3 and 'error' in app._messages[-1] + + assert dialite.ask_ok() + assert len(app._messages) == 4 and 'question' in app._messages[-1] + + assert dialite.ask_retry() + assert len(app._messages) == 5 and 'question' in app._messages[-1] + + assert dialite.ask_yesno() + assert len(app._messages) == 6 and 'question' in app._messages[-1] + + finally: + sys.platform = o_platform + dialite._the_app = o_app + + +def test_osx(): + """ Pretend that this is OS X. """ + + o_platform = sys.platform + o_app = dialite._the_app + sys.platform = 'darwin' + + try: + + app = FakeOSXApp() + # assert app.works() + assert isinstance(app, OSXApp) + dialite._the_app = app + + assert dialite.is_supported() + + dialite.inform() + assert len(app._messages) == 1 + + dialite.warn() + assert len(app._messages) == 2 + + dialite.fail() + assert len(app._messages) == 3 + + assert dialite.ask_ok() + assert len(app._messages) == 4 + + assert dialite.ask_retry() + assert len(app._messages) == 5 + + assert dialite.ask_yesno() + assert len(app._messages) == 6 + + finally: + sys.platform = o_platform + dialite._the_app = o_app + + +def test_unsupported_platform1(): + """ Unsupported platform, fallback to terminal. """ + + o_platform = sys.platform + o_stdin = sys.stdin + o_app = dialite._the_app + + sys.platform = 'meh' + + sys.stdin = FakeStdin() + + try: + + app = dialite._get_app(True) + assert app.works() + assert isinstance(app, TerminalApp) + + assert dialite.is_supported() + + with capture_log('info') as log: + dialite.inform() + assert len(log) == 1 and 'Info: ' in log[0] + + with capture_log('info') as log: + dialite.warn() # no problem + assert len(log) == 1 and 'Warning: ' in log[0] + + with capture_log('info') as log: + dialite.fail() + assert len(log) == 1 and 'Error: ' in log[0] + + assert dialite.ask_ok() + assert dialite.ask_retry() + assert dialite.ask_yesno() + + sys.stdin.answer = 'no' + assert not dialite.ask_ok() + assert not dialite.ask_retry() + assert not dialite.ask_yesno() + + finally: + sys.platform = o_platform + sys.stdin = o_stdin + dialite._the_app = o_app + + +def test_unsupported_platform2(): + """ Unsupported platform, and also no terminal. """ + + o_platform = sys.platform + o_stdin = sys.stdin + o_app = dialite._the_app + o_open = webbrowser.open + + sys.platform = 'meh' + sys.stdin = None + webbrowser.open = lambda x:None + + try: + + app = dialite._get_app(True) + assert app.works() + assert isinstance(app, StubApp) + + assert not dialite.is_supported() + + dialite.inform() # no problem + + dialite.warn() # no problem + + dialite.fail() # no problem + # with raises(SystemExit): + # dialite.fail() + + with raises(SystemExit): + dialite.ask_ok() + + with raises(SystemExit): + dialite.ask_retry() + + with raises(SystemExit): + dialite.ask_yesno() + + finally: + sys.platform = o_platform + sys.stdin = o_stdin + dialite._the_app = o_app + webbrowser.open = o_open
