[Python-modules-commits] [python-secretstorage] 01/05: Import python-secretstorage_2.1.3.orig.tar.gz
Dmitry Shachnev
mitya57 at moszumanska.debian.org
Sun Dec 20 19:25:43 UTC 2015
This is an automated email from the git hooks/post-receive script.
mitya57 pushed a commit to branch master
in repository python-secretstorage.
commit fb2fc584239179c0564cbea724dd6077210967d2
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date: Sun Dec 20 22:10:45 2015 +0300
Import python-secretstorage_2.1.3.orig.tar.gz
---
.gitignore | 6 ++
PKG-INFO | 31 +++++-
README.rst | 25 ++++-
SecretStorage.egg-info/PKG-INFO | 31 +++++-
SecretStorage.egg-info/SOURCES.txt | 2 +
SecretStorage.egg-info/requires.txt | 1 +
changelog | 8 ++
docs/conf.py | 191 +-----------------------------------
docs/index.rst | 3 +-
secretstorage/__init__.py | 20 +++-
secretstorage/collection.py | 3 -
secretstorage/item.py | 4 +-
secretstorage/util.py | 9 +-
setup.cfg | 2 +-
setup.py | 7 +-
tests/test_compat_functions.py | 36 ++++---
16 files changed, 151 insertions(+), 228 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b50f5c6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+build
+dist
+MANIFEST
+__pycache__
+*.pyc
+SecretStorage.egg-info
diff --git a/PKG-INFO b/PKG-INFO
index b2f9cf9..a802c47 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,7 +1,7 @@
Metadata-Version: 1.1
Name: SecretStorage
-Version: 2.1.2
-Summary: Secure storing of passwords and other secrets
+Version: 2.1.3
+Summary: Python bindings to FreeDesktop.org Secret Service API
Home-page: https://github.com/mitya57/secretstorage
Author: Dmitry Shachnev
Author-email: mitya57 at gmail.com
@@ -32,7 +32,7 @@ Description:
===================
.. note::
- SecretStorage supports all versions of Python since 2.6. Here we assume
+ SecretStorage supports all versions of Python since 2.7. Here we assume
that your Python version is 3.x.
SecretStorage requires these packages to work:
@@ -53,6 +53,29 @@ Description:
.. _`available on PyPI`: https://pypi.python.org/pypi/pycrypto
.. _Sphinx: http://sphinx-doc.org/
+ Testing the module
+ ==================
+
+ First, make sure that you have the Secret Service daemon installed.
+ The `GNOME Keyring`_ is the reference server-side implementation for the
+ Secret Service specification.
+
+ .. _`GNOME Keyring`: https://download.gnome.org/sources/gnome-keyring/
+
+ Then, start the daemon and unlock the ``default`` collection, if needed.
+ The testsuite will fail to run if the ``default`` collection exists and is
+ locked. If it does not exist, the testsuite can also use the temporary
+ ``session`` collection, as provided by the GNOME Keyring.
+
+ Then, run the Python unittest module::
+
+ python3 -m unittest discover -s tests
+
+ If you want to run the tests in an isolated or headless environment, run
+ this command in a D-Bus session::
+
+ dbus-run-session -- python3 -m unittest discover -s tests
+
Get the code
============
@@ -67,13 +90,13 @@ Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires: dbus
diff --git a/README.rst b/README.rst
index 129f371..eb13d24 100644
--- a/README.rst
+++ b/README.rst
@@ -23,7 +23,7 @@ Building the module
===================
.. note::
- SecretStorage supports all versions of Python since 2.6. Here we assume
+ SecretStorage supports all versions of Python since 2.7. Here we assume
that your Python version is 3.x.
SecretStorage requires these packages to work:
@@ -44,6 +44,29 @@ If you have Sphinx_ installed, you can also build the documentation::
.. _`available on PyPI`: https://pypi.python.org/pypi/pycrypto
.. _Sphinx: http://sphinx-doc.org/
+Testing the module
+==================
+
+First, make sure that you have the Secret Service daemon installed.
+The `GNOME Keyring`_ is the reference server-side implementation for the
+Secret Service specification.
+
+.. _`GNOME Keyring`: https://download.gnome.org/sources/gnome-keyring/
+
+Then, start the daemon and unlock the ``default`` collection, if needed.
+The testsuite will fail to run if the ``default`` collection exists and is
+locked. If it does not exist, the testsuite can also use the temporary
+``session`` collection, as provided by the GNOME Keyring.
+
+Then, run the Python unittest module::
+
+ python3 -m unittest discover -s tests
+
+If you want to run the tests in an isolated or headless environment, run
+this command in a D-Bus session::
+
+ dbus-run-session -- python3 -m unittest discover -s tests
+
Get the code
============
diff --git a/SecretStorage.egg-info/PKG-INFO b/SecretStorage.egg-info/PKG-INFO
index b2f9cf9..a802c47 100644
--- a/SecretStorage.egg-info/PKG-INFO
+++ b/SecretStorage.egg-info/PKG-INFO
@@ -1,7 +1,7 @@
Metadata-Version: 1.1
Name: SecretStorage
-Version: 2.1.2
-Summary: Secure storing of passwords and other secrets
+Version: 2.1.3
+Summary: Python bindings to FreeDesktop.org Secret Service API
Home-page: https://github.com/mitya57/secretstorage
Author: Dmitry Shachnev
Author-email: mitya57 at gmail.com
@@ -32,7 +32,7 @@ Description:
===================
.. note::
- SecretStorage supports all versions of Python since 2.6. Here we assume
+ SecretStorage supports all versions of Python since 2.7. Here we assume
that your Python version is 3.x.
SecretStorage requires these packages to work:
@@ -53,6 +53,29 @@ Description:
.. _`available on PyPI`: https://pypi.python.org/pypi/pycrypto
.. _Sphinx: http://sphinx-doc.org/
+ Testing the module
+ ==================
+
+ First, make sure that you have the Secret Service daemon installed.
+ The `GNOME Keyring`_ is the reference server-side implementation for the
+ Secret Service specification.
+
+ .. _`GNOME Keyring`: https://download.gnome.org/sources/gnome-keyring/
+
+ Then, start the daemon and unlock the ``default`` collection, if needed.
+ The testsuite will fail to run if the ``default`` collection exists and is
+ locked. If it does not exist, the testsuite can also use the temporary
+ ``session`` collection, as provided by the GNOME Keyring.
+
+ Then, run the Python unittest module::
+
+ python3 -m unittest discover -s tests
+
+ If you want to run the tests in an isolated or headless environment, run
+ this command in a D-Bus session::
+
+ dbus-run-session -- python3 -m unittest discover -s tests
+
Get the code
============
@@ -67,13 +90,13 @@ Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires: dbus
diff --git a/SecretStorage.egg-info/SOURCES.txt b/SecretStorage.egg-info/SOURCES.txt
index c646930..8fc523e 100644
--- a/SecretStorage.egg-info/SOURCES.txt
+++ b/SecretStorage.egg-info/SOURCES.txt
@@ -1,3 +1,4 @@
+.gitignore
LICENSE
MANIFEST.in
README.rst
@@ -6,6 +7,7 @@ setup.py
SecretStorage.egg-info/PKG-INFO
SecretStorage.egg-info/SOURCES.txt
SecretStorage.egg-info/dependency_links.txt
+SecretStorage.egg-info/requires.txt
SecretStorage.egg-info/top_level.txt
docs/collection.rst
docs/conf.py
diff --git a/SecretStorage.egg-info/requires.txt b/SecretStorage.egg-info/requires.txt
new file mode 100644
index 0000000..904545b
--- /dev/null
+++ b/SecretStorage.egg-info/requires.txt
@@ -0,0 +1 @@
+pycrypto
diff --git a/changelog b/changelog
index ed6c4a5..953d7f0 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,11 @@
+SecretStorage 2.1.3, 2015-12-20
+===============================
+
+* Python 2.6 is no longer supported.
+* Compatibility functions are now deprecated and will be removed in
+ the next major release.
+* Other minor fixes, simplifications and improvements.
+
SecretStorage 2.1.2, 2015-06-30
===============================
diff --git a/docs/conf.py b/docs/conf.py
index df236af..c05b2c1 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,16 +1,4 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-#
-# SecretStorage documentation build configuration file, created by
-# sphinx-quickstart on Fri Dec 28 17:17:46 2012.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
import sys, os
@@ -21,9 +9,6 @@ sys.path.insert(0, os.path.abspath('..'))
# -- General configuration -----------------------------------------------------
-# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
-
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
@@ -34,9 +19,6 @@ templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
-# The encoding of source files.
-#source_encoding = 'utf-8-sig'
-
# The master toctree document.
master_doc = 'index'
@@ -51,193 +33,22 @@ copyright = '2015, Dmitry Shachnev'
# The short X.Y version.
version = '2.1'
# The full version, including alpha/beta/rc tags.
-release = '2.1.2'
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#language = None
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
-exclude_patterns = ['_build']
-
-# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
-
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
+release = '2.1.3'
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
-# Theme options are theme-specific and customize the look and feel of a theme
-# further. For a list of options available for each theme, see the
-# documentation.
-#html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The name for this set of Sphinx documents. If None, it defaults to
-# "<project> v<release> documentation".
-#html_title = None
-
-# A shorter title for the navigation bar. Default is the same as html_title.
-#html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-#html_static_path = ['_static']
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-#html_domain_indices = True
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it. The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# This is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = None
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'SecretStorageDoc'
-
-
# -- Options for LaTeX output --------------------------------------------------
-latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-#'papersize': 'letterpaper',
-
-# The font size ('10pt', '11pt' or '12pt').
-#'pointsize': '10pt',
-
-# Additional stuff for the LaTeX preamble.
-#'preamble': '',
-}
-
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'SecretStorage.tex', 'SecretStorage Documentation',
'Dmitry Shachnev', 'manual'),
]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-
-# -- Options for manual page output --------------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
- ('index', 'secretstorage', 'SecretStorage Documentation',
- ['Dmitry Shachnev'], 1)
-]
-
-# If true, show URL addresses after external links.
-#man_show_urls = False
-
-
-# -- Options for Texinfo output ------------------------------------------------
-
-# Grouping the document tree into Texinfo files. List of tuples
-# (source start file, target name, title, author,
-# dir menu entry, description, category)
-texinfo_documents = [
- ('index', 'SecretStorage', 'SecretStorage Documentation',
- 'Dmitry Shachnev', 'SecretStorage', 'One line description of project.',
- 'Miscellaneous'),
-]
-
-# Documents to append as an appendix to all manuals.
-#texinfo_appendices = []
-
-# If false, no module index is generated.
-#texinfo_domain_indices = True
-
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#texinfo_show_urls = 'footnote'
diff --git a/docs/index.rst b/docs/index.rst
index 358a93c..d2e0206 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -43,7 +43,7 @@ Creating a new item in the default collection:
>>> import secretstorage
>>> bus = secretstorage.dbus_init()
->>> collection = secretstorage.Collection(bus)
+>>> collection = secretstorage.get_default_collection(bus)
>>> attributes = {'application': 'myapp', 'another attribute':
... 'another value'}
>>> item = collection.create_item('My first item', attributes,
@@ -51,7 +51,6 @@ Creating a new item in the default collection:
Getting item's label, attributes and secret:
->>> item = collection.create_item('My first item', attributes, b'pa$$word')
>>> item.get_label()
'My first item'
>>> item.get_attributes()
diff --git a/secretstorage/__init__.py b/secretstorage/__init__.py
index 105fc7d..6a4810c 100644
--- a/secretstorage/__init__.py
+++ b/secretstorage/__init__.py
@@ -21,8 +21,10 @@ from secretstorage.exceptions import SecretStorageException, \
SecretServiceNotAvailableException, LockedException, \
ItemNotFoundException
from os.path import join
+from functools import wraps
+from warnings import warn
-__version_tuple__ = (2, 1, 2)
+__version_tuple__ = (2, 1, 3)
__version__ = '.'.join(map(str, __version_tuple__))
def dbus_init(main_loop=True, use_qt_loop=False):
@@ -56,6 +58,16 @@ def dbus_init(main_loop=True, use_qt_loop=False):
# The functions below are provided for compatibility with old
# SecretStorage versions (<= 0.2).
+def _deprecated(function_in):
+ @wraps(function_in)
+ def function_out(*args, **kwargs):
+ warn('Function %s is deprecated. Please use the documented API'
+ ' instead.' % function_in.__name__, DeprecationWarning,
+ stacklevel=2)
+ return function_in(*args, **kwargs)
+ return function_out
+
+ at _deprecated
def get_items(search_attributes, unlock_all=True):
"""Returns tuples for all items in the default collection matching
`search_attributes`."""
@@ -66,6 +78,7 @@ def get_items(search_attributes, unlock_all=True):
search_results = collection.search_items(search_attributes)
return [item.to_tuple() for item in search_results]
+ at _deprecated
def get_items_ids(search_attributes):
"""Returns item id for all items in the default collection matching
`search_attributes`."""
@@ -74,6 +87,7 @@ def get_items_ids(search_attributes):
search_results = collection.search_items(search_attributes)
return [item._item_id() for item in search_results]
+ at _deprecated
def get_item_attributes(item_id):
"""Returns item attributes for item with given id."""
bus = dbus_init()
@@ -81,6 +95,7 @@ def get_item_attributes(item_id):
item = Item(bus, join(collection.collection_path, str(item_id)))
return item.get_attributes()
+ at _deprecated
def get_item_object(item_id, unlock=True):
"""Returns the item with given id and unlocks it if `unlock` is
`True`."""
@@ -91,14 +106,17 @@ def get_item_object(item_id, unlock=True):
collection.unlock()
return item
+ at _deprecated
def get_item(item_id, unlock=True):
"""Returns tuple representing the item with given id."""
return get_item_object(item_id, unlock).to_tuple()
+ at _deprecated
def delete_item(item_id, unlock=True):
"""Deletes the item with given id."""
return get_item_object(item_id, unlock).delete()
+ at _deprecated
def create_item(label, attributes, secret, unlock=True):
"""Creates an item with given `label`, `attributes` and `secret` in
the default collection. Returns id of the created item."""
diff --git a/secretstorage/collection.py b/secretstorage/collection.py
index 4cbb5f3..d48823e 100644
--- a/secretstorage/collection.py
+++ b/secretstorage/collection.py
@@ -84,9 +84,6 @@ class Collection(object):
`attributes` should be a dictionary."""
result = self.collection_iface.SearchItems(attributes,
signature='a{ss}')
- if isinstance(result, tuple):
- # bug in GNOME Keyring <= 3.7.5
- result = result[0] + result[1]
for item_path in result:
yield Item(self.bus, item_path, self.session)
diff --git a/secretstorage/item.py b/secretstorage/item.py
index b4f9cd1..a1d8257 100644
--- a/secretstorage/item.py
+++ b/secretstorage/item.py
@@ -68,8 +68,8 @@ class Item(object):
"""Returns item attributes (dictionary)."""
attrs = self.item_props_iface.Get(ITEM_IFACE, 'Attributes',
signature='ss')
- return dict([(to_unicode(key), to_unicode(value))
- for key, value in attrs.items()])
+ return {to_unicode(key): to_unicode(value)
+ for key, value in attrs.items()}
def set_attributes(self, attributes):
"""Sets item attributes to `attributes` (dictionary)."""
diff --git a/secretstorage/util.py b/secretstorage/util.py
index 1a71f86..7308a6b 100644
--- a/secretstorage/util.py
+++ b/secretstorage/util.py
@@ -151,7 +151,8 @@ def unlock_objects(bus, paths, callback=None):
representing whether the operation was dismissed."""
service_obj = bus_get_object(bus, SECRETS, SS_PATH)
service_iface = InterfaceWrapper(service_obj, SERVICE_IFACE)
- prompt = service_iface.Unlock(paths, signature='ao')[1]
+ unlocked_paths, prompt = service_iface.Unlock(paths, signature='ao')
+ unlocked_paths = list(unlocked_paths) # Convert from dbus.Array
if len(prompt) > 1:
if callback:
exec_prompt(bus, prompt, callback)
@@ -159,11 +160,7 @@ def unlock_objects(bus, paths, callback=None):
return exec_prompt_glib(bus, prompt)[0]
elif callback:
# We still need to call it.
- callback(False, [])
-
-# Compatibility aliases
-exec_prompt_async_glib = exec_prompt_glib
-exec_prompt_async_qt = exec_prompt_qt
+ callback(False, unlocked_paths)
def to_unicode(string):
"""Converts D-Bus string to unicode string."""
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..6bc2ff3 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
[egg_info]
-tag_build =
tag_date = 0
+tag_build =
tag_svn_revision = 0
diff --git a/setup.py b/setup.py
index 5085146..a8ffe0a 100755
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ try:
except ImportError:
from distutils.core import setup
-version = '2.1.2'
+version = '2.1.3'
readme_file = open(os.path.join(os.path.dirname(__file__), 'README.rst'))
long_description = '\n' + readme_file.read()
@@ -18,20 +18,20 @@ classifiers = [
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
'Topic :: Security',
'Topic :: Software Development :: Libraries :: Python Modules'
]
setup(name='SecretStorage',
version=version,
- description='Secure storing of passwords and other secrets',
+ description='Python bindings to FreeDesktop.org Secret Service API',
long_description=long_description,
author='Dmitry Shachnev',
author_email='mitya57 at gmail.com',
@@ -40,5 +40,6 @@ setup(name='SecretStorage',
platforms='Linux',
license='BSD',
classifiers=classifiers,
+ install_requires=['pycrypto'],
requires=['dbus', 'Crypto']
)
diff --git a/tests/test_compat_functions.py b/tests/test_compat_functions.py
index f9c17fb..e59ec2b 100644
--- a/tests/test_compat_functions.py
+++ b/tests/test_compat_functions.py
@@ -13,37 +13,51 @@ rand = str(random.randint(0, 1000))
ATTRIBUTES = {'application': 'secretstorage-test', 'attribute': rand}
PASSWORD = b'pa$$word'
+def catch_deprecation_warnings(testcase, function_in):
+ if not hasattr(testcase, 'assertWarns'):
+ return function_in
+ def function_out(*args, **kwargs):
+ with testcase.assertWarns(DeprecationWarning):
+ return function_in(*args, **kwargs)
+ return function_out
+
class CompatFunctionsTest(unittest.TestCase):
"""A test case that tests compatibility functions, based on old
SecretStorage test."""
- @classmethod
- def setUpClass(cls):
- cls.item_id = secretstorage.create_item('Test item',
- ATTRIBUTES, PASSWORD)
+ def __init__(self, *args, **kwargs):
+ unittest.TestCase.__init__(self, *args, **kwargs)
+ self.create_item = catch_deprecation_warnings(self, secretstorage.create_item)
+ self.get_items = catch_deprecation_warnings(self, secretstorage.get_items)
+ self.get_items_ids = catch_deprecation_warnings(self, secretstorage.get_items_ids)
+ self.get_item = catch_deprecation_warnings(self, secretstorage.get_item)
+ self.get_item_attributes = catch_deprecation_warnings(self, secretstorage.get_item_attributes)
+ self.delete_item = catch_deprecation_warnings(self, secretstorage.delete_item)
+
+ def setUp(self):
+ self.item_id = self.create_item('Test item', ATTRIBUTES, PASSWORD)
def test_get_items(self):
- attrs, secret = secretstorage.get_items(ATTRIBUTES)[-1]
+ attrs, secret = self.get_items(ATTRIBUTES)[-1]
self.assertEqual(attrs['application'], 'secretstorage-test')
self.assertEqual(secret, PASSWORD)
def test_get_items_ids(self):
- item_id = secretstorage.get_items_ids(ATTRIBUTES)[-1]
+ item_id = self.get_items_ids(ATTRIBUTES)[-1]
self.assertEqual(item_id, self.item_id)
def test_get_item(self):
- attrs, secret = secretstorage.get_item(self.item_id)
+ attrs, secret = self.get_item(self.item_id)
self.assertEqual(attrs['application'], 'secretstorage-test')
self.assertEqual(secret, PASSWORD)
def test_get_item_attributes(self):
- attrs = secretstorage.get_item_attributes(self.item_id)
+ attrs = self.get_item_attributes(self.item_id)
self.assertEqual(attrs['application'], 'secretstorage-test')
self.assertEqual(attrs['attribute'], rand)
- @classmethod
- def tearDownClass(cls):
- secretstorage.delete_item(cls.item_id)
+ def tearDown(self):
+ self.delete_item(self.item_id)
if __name__ == '__main__':
unittest.main()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-secretstorage.git
More information about the Python-modules-commits
mailing list