File python-fudge.spec of Package python-fudge

#
# spec file for package python-fudge
#
# Copyright (c) 2017 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
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-fudge
Version:        1.1.0
Release:        0
Summary:        Replace real objects with fakes (mocks, stubs, etc) while testing
License:        MIT
Group:          Development/Languages/Python
Url:            http://farmdev.com/projects/fudge/
Source:         https://files.pythonhosted.org/packages/source/f/fudge/fudge-%{version}.tar.gz
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module nose}
BuildRequires:  python-rpm-macros
BuildRequires:  python3-2to3
BuildRequires:  python3-Sphinx
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%python_subpackages

%description
Complete documentation is available at http://farmdev.com/projects/fudge/

Fudge is a Python module for using fake objects (mocks and stubs) to test real ones.

In readable Python code, you declare what methods are available on your fake and
how they should be called. Then you inject that into your application and start
testing. This declarative approach means you don't have to record and playback
actions and you don't have to inspect your fakes after running code. If the fake
object was used incorrectly then you'll see an informative exception message
with a traceback that points to the culprit.

Here is a quick preview of how you can test code that sends
email without actually sending email::

    @fudge.patch('smtplib.SMTP')
    def test_mailer(FakeSMTP):
        # Declare how the SMTP class should be used:
        (FakeSMTP.expects_call()
                 .expects('connect')
                 .expects('sendmail').with_arg_count(3))
        # Run production code:
        send_mail()
        # ...expectations are verified automatically at the end of the test

%prep
%setup -q -n fudge-%{version}
# drop build date from doc to fix build-compare
sed -i "s/\(html_last_updated_fmt = \).*/\\1None/" ./docs/conf.py

%build
%python_build
cd docs && make html && rm -r _build/html/.buildinfo # Build HTML documentation

%install
%python_install

%check
mkdir testdir
pushd testdir
cp -r ../fudge/tests tests2
export PYTHONPATH=%{buildroot}%{python2_sitelib}
nosetests-%{python2_bin_suffix} -w tests2
cp -r ../fudge/tests tests3
2to3 -w tests3
export PYTHONPATH=%{buildroot}%{python3_sitelib}
nosetests-%{python3_bin_suffix} -w tests3
popd

%files %{python_files}
%defattr(-,root,root,-)
%license LICENSE.txt
%doc docs/_build/html
%{python_sitelib}/*

%changelog
openSUSE Build Service is sponsored by