forked from pool/python-minidb
Accepting request 789080 from devel:languages:python
OBS-URL: https://build.opensuse.org/request/show/789080 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-minidb?expand=0&rev=4
This commit is contained in:
388
0001-switch-to-pytest.patch
Normal file
388
0001-switch-to-pytest.patch
Normal file
@@ -0,0 +1,388 @@
|
|||||||
|
From ac709c48385583a0309ff850cd31896d5f19f647 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paolo Stivanin <info@paolostivanin.com>
|
||||||
|
Date: Fri, 27 Mar 2020 14:47:48 +0100
|
||||||
|
Subject: [PATCH] switch to pytest
|
||||||
|
|
||||||
|
---
|
||||||
|
test/test_minidb.py | 227 ++++++++++++++++++++++----------------------
|
||||||
|
1 file changed, 115 insertions(+), 112 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/test/test_minidb.py b/test/test_minidb.py
|
||||||
|
index 8f6d44a..632aeec 100644
|
||||||
|
--- a/test/test_minidb.py
|
||||||
|
+++ b/test/test_minidb.py
|
||||||
|
@@ -1,8 +1,11 @@
|
||||||
|
import minidb
|
||||||
|
+import pytest
|
||||||
|
+import datetime
|
||||||
|
|
||||||
|
-from nose.tools import *
|
||||||
|
|
||||||
|
-import datetime
|
||||||
|
+def ported_eq(a, b, msg=None):
|
||||||
|
+ if not a == b:
|
||||||
|
+ raise AssertionError(msg or "%r != %r" % (a, b))
|
||||||
|
|
||||||
|
|
||||||
|
class FieldTest(minidb.Model):
|
||||||
|
@@ -138,38 +141,38 @@ def test_loading_objects():
|
||||||
|
assert field_test._private1 == 997
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(minidb.UnknownClass)
|
||||||
|
def test_saving_without_registration_fails():
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- FieldTest(9).save(db)
|
||||||
|
+ with pytest.raises(minidb.UnknownClass):
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ FieldTest(9).save(db)
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(TypeError)
|
||||||
|
def test_registering_non_subclass_of_model_fails():
|
||||||
|
# This cannot be registered, as it's not a subclass of minidb.Model
|
||||||
|
- class Something(object):
|
||||||
|
- column = str
|
||||||
|
+ with pytest.raises(TypeError):
|
||||||
|
+ class Something(object):
|
||||||
|
+ column = str
|
||||||
|
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- db.register(Something)
|
||||||
|
- db.register(Something)
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ db.register(Something)
|
||||||
|
+ db.register(Something)
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(KeyError)
|
||||||
|
def test_invalid_keyword_arguments_fails():
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- db.register(FieldTest)
|
||||||
|
- FieldTest(9, this_is_not_an_attribute=123).save(db)
|
||||||
|
+ with pytest.raises(KeyError):
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ db.register(FieldTest)
|
||||||
|
+ FieldTest(9, this_is_not_an_attribute=123).save(db)
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(AttributeError)
|
||||||
|
def test_invalid_column_raises_attribute_error():
|
||||||
|
- class HasOnlyColumnX(minidb.Model):
|
||||||
|
- x = int
|
||||||
|
+ with pytest.raises(AttributeError):
|
||||||
|
+ class HasOnlyColumnX(minidb.Model):
|
||||||
|
+ x = int
|
||||||
|
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- db.register(HasOnlyColumnX)
|
||||||
|
- HasOnlyColumnX.c.y
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ db.register(HasOnlyColumnX)
|
||||||
|
+ HasOnlyColumnX.c.y
|
||||||
|
|
||||||
|
|
||||||
|
def test_json_serialization():
|
||||||
|
@@ -192,7 +195,7 @@ def test_json_field_query():
|
||||||
|
db.register(WithJsonField)
|
||||||
|
d = {'a': [1, True, 3.9]}
|
||||||
|
WithJsonField(bar=d).save(db)
|
||||||
|
- eq_(next(WithJsonField.c.bar.query(db)).bar, d)
|
||||||
|
+ ported_eq(next(WithJsonField.c.bar.query(db)).bar, d)
|
||||||
|
|
||||||
|
|
||||||
|
def test_json_field_renamed_query():
|
||||||
|
@@ -203,7 +206,7 @@ def test_json_field_renamed_query():
|
||||||
|
db.register(WithJsonField)
|
||||||
|
d = {'a': [1, True, 3.9]}
|
||||||
|
WithJsonField(bar=d).save(db)
|
||||||
|
- eq_(next(WithJsonField.c.bar('renamed').query(db)).renamed, d)
|
||||||
|
+ ported_eq(next(WithJsonField.c.bar('renamed').query(db)).renamed, d)
|
||||||
|
|
||||||
|
|
||||||
|
def test_field_conversion_get_object():
|
||||||
|
@@ -293,16 +296,16 @@ def test_storing_and_retrieving_bytes():
|
||||||
|
assert query_value == BLOB
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(ValueError)
|
||||||
|
def test_get_with_multiple_value_raises_exception():
|
||||||
|
- class Mod(minidb.Model):
|
||||||
|
- mod = str
|
||||||
|
+ with pytest.raises(ValueError):
|
||||||
|
+ class Mod(minidb.Model):
|
||||||
|
+ mod = str
|
||||||
|
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- db.register(Mod)
|
||||||
|
- Mod(mod='foo').save(db)
|
||||||
|
- Mod(mod='foo').save(db)
|
||||||
|
- Mod.get(db, mod='foo')
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ db.register(Mod)
|
||||||
|
+ Mod(mod='foo').save(db)
|
||||||
|
+ Mod(mod='foo').save(db)
|
||||||
|
+ Mod.get(db, mod='foo')
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_with_no_value_returns_none():
|
||||||
|
@@ -329,72 +332,72 @@ def test_delete_where():
|
||||||
|
assert {2, 3, 4, 5} == {v for (v,) in DeleteWhere.c.v.query(db)}
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(AttributeError)
|
||||||
|
def test_invalid_rowproxy_access_by_attribute():
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = str
|
||||||
|
+ with pytest.raises(AttributeError):
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = str
|
||||||
|
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- db.register(Foo)
|
||||||
|
- Foo(bar='baz').save(db)
|
||||||
|
- next(Foo.query(db, Foo.c.bar)).baz
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ db.register(Foo)
|
||||||
|
+ Foo(bar='baz').save(db)
|
||||||
|
+ next(Foo.query(db, Foo.c.bar)).baz
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(KeyError)
|
||||||
|
def test_invalid_rowproxy_access_by_key():
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = str
|
||||||
|
+ with pytest.raises(KeyError):
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = str
|
||||||
|
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- db.register(Foo)
|
||||||
|
- Foo(bar='baz').save(db)
|
||||||
|
- next(Foo.query(db, Foo.c.bar))['baz']
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ db.register(Foo)
|
||||||
|
+ Foo(bar='baz').save(db)
|
||||||
|
+ next(Foo.query(db, Foo.c.bar))['baz']
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(TypeError)
|
||||||
|
def test_use_schema_without_registration_raises_typeerror():
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = str
|
||||||
|
- Foo.query(db)
|
||||||
|
+ with pytest.raises(TypeError):
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = str
|
||||||
|
+ Foo.query(db)
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(TypeError)
|
||||||
|
def test_use_schema_with_nonidentity_class_raises_typeerror():
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = str
|
||||||
|
- db.register(Foo)
|
||||||
|
+ with pytest.raises(TypeError):
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = str
|
||||||
|
+ db.register(Foo)
|
||||||
|
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = str
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = str
|
||||||
|
|
||||||
|
- Foo.query(db)
|
||||||
|
+ Foo.query(db)
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(TypeError)
|
||||||
|
def test_upgrade_schema_without_upgrade_raises_typeerror():
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = str
|
||||||
|
+ with pytest.raises(TypeError):
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = str
|
||||||
|
|
||||||
|
- db.register(Foo)
|
||||||
|
+ db.register(Foo)
|
||||||
|
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = str
|
||||||
|
- baz = int
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = str
|
||||||
|
+ baz = int
|
||||||
|
|
||||||
|
- db.register(Foo)
|
||||||
|
+ db.register(Foo)
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(TypeError)
|
||||||
|
def test_reregistering_class_raises_typeerror():
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = int
|
||||||
|
+ with pytest.raises(TypeError):
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = int
|
||||||
|
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- db.register(Foo)
|
||||||
|
- db.register(Foo)
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ db.register(Foo)
|
||||||
|
+ db.register(Foo)
|
||||||
|
|
||||||
|
|
||||||
|
def test_upgrade_schema_with_upgrade_succeeds():
|
||||||
|
@@ -411,18 +414,18 @@ def test_upgrade_schema_with_upgrade_succeeds():
|
||||||
|
db.register(Foo, upgrade=True)
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(TypeError)
|
||||||
|
def test_upgrade_schema_with_different_type_raises_typeerror():
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = str
|
||||||
|
+ with pytest.raises(TypeError):
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = str
|
||||||
|
|
||||||
|
- db.register(Foo)
|
||||||
|
+ db.register(Foo)
|
||||||
|
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = int
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = int
|
||||||
|
|
||||||
|
- db.register(Foo, upgrade=True)
|
||||||
|
+ db.register(Foo, upgrade=True)
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_object():
|
||||||
|
@@ -474,11 +477,11 @@ def test_distinct():
|
||||||
|
|
||||||
|
# minidb.func.distinct(COLUMN)(NAME)
|
||||||
|
result = {tuple(x) for x in Foo.query(db, lambda c: minidb.func.distinct(c.bar)('foo'))}
|
||||||
|
- eq_(result, expected)
|
||||||
|
+ ported_eq(result, expected)
|
||||||
|
|
||||||
|
# COLUMN.distinct(NAME)
|
||||||
|
result = {tuple(x) for x in Foo.query(db, Foo.c.bar.distinct('foo'))}
|
||||||
|
- eq_(result, expected)
|
||||||
|
+ ported_eq(result, expected)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -501,43 +504,43 @@ def test_group_by_with_sum():
|
||||||
|
# minidb.func.sum(COLUMN)(NAME)
|
||||||
|
result = {tuple(x) for x in Foo.query(db, lambda c: c.bar //
|
||||||
|
minidb.func.sum(c.baz)('sum'), group_by=lambda c: c.bar)}
|
||||||
|
- eq_(result, expected)
|
||||||
|
+ ported_eq(result, expected)
|
||||||
|
|
||||||
|
# COLUMN.sum(NAME)
|
||||||
|
result = {tuple(x) for x in Foo.query(db, lambda c: c.bar //
|
||||||
|
c.baz.sum('sum'), group_by=lambda c: c.bar)}
|
||||||
|
- eq_(result, expected)
|
||||||
|
+ ported_eq(result, expected)
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(ValueError)
|
||||||
|
def test_save_without_db_raises_valueerror():
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = int
|
||||||
|
+ with pytest.raises(ValueError):
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = int
|
||||||
|
|
||||||
|
- Foo(bar=99).save()
|
||||||
|
+ Foo(bar=99).save()
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(ValueError)
|
||||||
|
def test_delete_without_db_raises_valueerror():
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = int
|
||||||
|
+ with pytest.raises(ValueError):
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = int
|
||||||
|
|
||||||
|
- Foo(bar=99).delete()
|
||||||
|
+ Foo(bar=99).delete()
|
||||||
|
|
||||||
|
|
||||||
|
-@raises(KeyError)
|
||||||
|
def test_double_delete_without_id_raises_valueerror():
|
||||||
|
- class Foo(minidb.Model):
|
||||||
|
- bar = str
|
||||||
|
+ with pytest.raises(KeyError):
|
||||||
|
+ class Foo(minidb.Model):
|
||||||
|
+ bar = str
|
||||||
|
|
||||||
|
- with minidb.Store(debug=True) as db:
|
||||||
|
- db.register(Foo)
|
||||||
|
- a = Foo(bar='hello')
|
||||||
|
- a.save(db)
|
||||||
|
- assert a.id is not None
|
||||||
|
- a.delete()
|
||||||
|
- assert a.id is None
|
||||||
|
- a.delete()
|
||||||
|
+ with minidb.Store(debug=True) as db:
|
||||||
|
+ db.register(Foo)
|
||||||
|
+ a = Foo(bar='hello')
|
||||||
|
+ a.save(db)
|
||||||
|
+ assert a.id is not None
|
||||||
|
+ a.delete()
|
||||||
|
+ assert a.id is None
|
||||||
|
+ a.delete()
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_values_are_set_if_none():
|
||||||
|
@@ -549,10 +552,10 @@ def test_default_values_are_set_if_none():
|
||||||
|
|
||||||
|
with minidb.Store(debug=True) as db:
|
||||||
|
f = Foo()
|
||||||
|
- eq_(f.name, 'Bob')
|
||||||
|
+ ported_eq(f.name, 'Bob')
|
||||||
|
|
||||||
|
f = Foo(name='John')
|
||||||
|
- eq_(f.name, 'John')
|
||||||
|
+ ported_eq(f.name, 'John')
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_values_with_callable():
|
||||||
|
@@ -569,16 +572,16 @@ def test_default_values_with_callable():
|
||||||
|
|
||||||
|
with minidb.Store(debug=True) as db:
|
||||||
|
f = Foo()
|
||||||
|
- eq_(f.name, 'Bob')
|
||||||
|
- eq_(f.email, 'Bob@example.com')
|
||||||
|
+ ported_eq(f.name, 'Bob')
|
||||||
|
+ ported_eq(f.email, 'Bob@example.com')
|
||||||
|
|
||||||
|
f = Foo(name='John')
|
||||||
|
- eq_(f.name, 'John')
|
||||||
|
- eq_(f.email, 'John@example.com')
|
||||||
|
+ ported_eq(f.name, 'John')
|
||||||
|
+ ported_eq(f.email, 'John@example.com')
|
||||||
|
|
||||||
|
f = Foo(name='Joe', email='joe@example.net')
|
||||||
|
- eq_(f.name, 'Joe')
|
||||||
|
- eq_(f.email, 'joe@example.net')
|
||||||
|
+ ported_eq(f.name, 'Joe')
|
||||||
|
+ ported_eq(f.email, 'joe@example.net')
|
||||||
|
|
||||||
|
|
||||||
|
def test_storing_and_retrieving_datetime():
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:43d59231556e9ed43d88c8c1ffcca30886b4db6436625599eeeb22bb9f74ab2b
|
|
||||||
size 13928
|
|
||||||
3
minidb-2.0.3.tar.gz
Normal file
3
minidb-2.0.3.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:1d6b490286887d8d7f05e12e858b483e226151c5ee9c5a171241e17f9b2dac54
|
||||||
|
size 13992
|
||||||
@@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Mar 27 14:01:08 UTC 2020 - Paolo Stivanin <info@paolostivanin.com>
|
||||||
|
|
||||||
|
- Update to 2.0.3
|
||||||
|
- Add 0001-switch-to-pytest.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Dec 4 12:50:23 UTC 2018 - Matej Cepl <mcepl@suse.com>
|
Tue Dec 4 12:50:23 UTC 2018 - Matej Cepl <mcepl@suse.com>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package python-minidb
|
# spec file for package python-minidb
|
||||||
#
|
#
|
||||||
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
|
# Copyright (c) 2020 SUSE LLC
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@@ -20,17 +20,19 @@
|
|||||||
%define skip_python2 1
|
%define skip_python2 1
|
||||||
%bcond_without test
|
%bcond_without test
|
||||||
Name: python-minidb
|
Name: python-minidb
|
||||||
Version: 2.0.2
|
Version: 2.0.3
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: SQLite3-based store for Python objects
|
Summary: SQLite3-based store for Python objects
|
||||||
License: ISC
|
License: ISC
|
||||||
Group: Development/Languages/Python
|
Group: Development/Languages/Python
|
||||||
Url: http://thp.io/2010/minidb/
|
URL: http://thp.io/2010/minidb/
|
||||||
Source: https://files.pythonhosted.org/packages/source/m/minidb/minidb-%{version}.tar.gz
|
Source: https://files.pythonhosted.org/packages/source/m/minidb/minidb-%{version}.tar.gz
|
||||||
|
# https://github.com/thp/minidb/pull/14
|
||||||
|
Patch0: 0001-switch-to-pytest.patch
|
||||||
BuildRequires: %{python_module setuptools}
|
BuildRequires: %{python_module setuptools}
|
||||||
BuildRequires: python-rpm-macros
|
BuildRequires: python-rpm-macros
|
||||||
%if %{with test}
|
%if %{with test}
|
||||||
BuildRequires: %{python_module nose}
|
BuildRequires: %{python_module pytest}
|
||||||
BuildRequires: python3-testsuite
|
BuildRequires: python3-testsuite
|
||||||
%endif
|
%endif
|
||||||
BuildRequires: fdupes
|
BuildRequires: fdupes
|
||||||
@@ -43,6 +45,7 @@ Minidb 2 allows you to store Python objects in a SQLite 3 database.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n minidb-%{version}
|
%setup -q -n minidb-%{version}
|
||||||
|
%patch0 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%python_build
|
%python_build
|
||||||
@@ -53,7 +56,7 @@ Minidb 2 allows you to store Python objects in a SQLite 3 database.
|
|||||||
|
|
||||||
%if %{with test}
|
%if %{with test}
|
||||||
%check
|
%check
|
||||||
%python_expand nosetests-%{$python_bin_suffix}
|
%pytest test/test_minidb.py
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%files %{python_files}
|
%files %{python_files}
|
||||||
|
|||||||
Reference in New Issue
Block a user