Browse files

Documentation improvment + minor fixes

  • Loading branch information...
1 parent fef2d42 commit 56e42583f08aaf5e6c25f16c8e7f1cc255a4f1e2 @kiddouk committed Sep 8, 2012
Showing with 1,241 additions and 110 deletions.
  1. +153 −0 Makefile
  2. +245 −0 conf.py
  3. +36 −0 containers.rst
  4. +24 −0 index.rst
  5. +21 −0 models.rst
  6. +758 −106 redisco/containers.py
  7. +4 −4 tests/containers.py
View
153 Makefile
@@ -0,0 +1,153 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Redisco.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Redisco.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/Redisco"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Redisco"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
View
245 conf.py
@@ -0,0 +1,245 @@
+# -*- coding: utf-8 -*-
+#
+# Redisco documentation build configuration file, created by
+# sphinx-quickstart on Fri Sep 7 15:58:04 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
+
+# Make sure that our current path is included
+sys.path.insert(0, ".")
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#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']
+
+# Add any paths that contain templates here, relative to this directory.
+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'
+
+# General information about the project.
+project = u'Redisco'
+copyright = u'2012, Sebastien Requiem'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.2.0'
+# The full version, including alpha/beta/rc tags.
+release = 'rc3'
+
+# 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
+
+# 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 = 'default'
+
+# 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 = 'Rediscodoc'
+
+
+# -- 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', 'Redisco.tex', u'Redisco Documentation',
+ u'Sebastien Requiem', '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', 'redisco', u'Redisco Documentation',
+ [u'Sebastien Requiem'], 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', 'Redisco', u'Redisco Documentation',
+ u'Sebastien Requiem', 'Redisco', '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'
View
36 containers.rst
@@ -0,0 +1,36 @@
+.. Redisco documentation contianers file, created by
+ sphinx-quickstart on Fri Sep 7 15:58:04 2012.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Containers
+===================================
+
+A suite of containers is available to the developer (you!) in order to manipulate some of redis' objects. You can easily create, modify, update, and delete Sets, SortedSets, Lists and Hashes. Pay attention that mnay of the operations are serialized to the redis server and are therefore time consuming.
+
+
+Base Class
+-----------------------------------
+.. autoclass:: redisco.containers.Container
+ :members:
+
+Set
+-----------------------------------
+.. autoclass:: redisco.containers.Set
+ :members:
+
+SortedSet
+-----------------------------------
+.. autoclass:: redisco.containers.SortedSet
+ :members:
+
+List
+-----------------------------------
+.. autoclass:: redisco.containers.List
+ :members:
+
+Hash
+-----------------------------------
+.. autoclass:: redisco.containers.Hash
+ :members:
+
View
24 index.rst
@@ -0,0 +1,24 @@
+.. Redisco documentation master file, created by
+ sphinx-quickstart on Fri Sep 7 15:58:04 2012.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to Redisco's documentation!
+===================================
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+ models
+ containers
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
View
21 models.rst
@@ -0,0 +1,21 @@
+.. Redisco documentation contianers file, created by
+ sphinx-quickstart on Fri Sep 7 15:58:04 2012.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Containers
+===================================
+
+A suite of containers is available to the developer (you!) in order to manipulate some of redis' objects. You can easily create, modify, update, and delete Sets, SortedSets, Lists and Hashes. Pay attention that mnay of the operations are serialized to the redis server and are therefore time consuming.
+
+
+Model
+-----------------------------------
+.. autoclass:: redisco.models.Model
+ :members:
+
+
+Modelset
+-----------------------------------
+.. autoclass:: redisco.models.modelset.ModelSet
+ :members:
View
864 redisco/containers.py
@@ -1,7 +1,5 @@
-"""
-This module contains the container classes to create objects
-that persist directly in a Redis server.
-"""
+# -*- coding: utf-8 -*-
+# doctest: +ELLIPSIS
import collections
from functools import partial
@@ -16,14 +14,11 @@ def _parse_values(values):
class Container(object):
- """Create a container object saved in Redis.
-
- Arguments:
- key -- the Redis key this container is stored at
- db -- the Redis client object. Default: None
-
- When ``db`` is not set, the gets the default connection from
- ``redisco.connection`` module.
+ """
+ Base class for all containers. This class should not
+ be used and does not provide anything except the ``db``
+ member.
+ :members:
"""
def __init__(self, key, db=None, pipeline=None):
@@ -32,10 +27,37 @@ def __init__(self, key, db=None, pipeline=None):
self.pipeline = pipeline
def clear(self):
- """Remove container from Redis database."""
+ """
+ Remove the container from the redis storage
+
+ >>> s = Set('test')
+ >>> s.add('1')
+ 1
+ >>> s.clear()
+ >>> s.members
+ set([])
+
+
+ """
del self.db[self.key]
def set_expire(self, time=None):
+ """
+ Allow the key to expire after ``time`` seconds.
+
+ >>> s = Set("test")
+ >>> s.add("1")
+ 1
+ >>> s.set_expire(1)
+ >>> from time import sleep
+ >>> sleep(1)
+ >>> s.members
+ set([])
+
+
+ :param time: time expressed in seconds. If time is not specified, then ``default_expire_time`` will be used.
+ :rtype: None
+ """
if time is None:
time = default_expire_time
self.db.expire(self.key, time)
@@ -55,123 +77,309 @@ def db(self):
class Set(Container):
- """A set stored in Redis."""
+ """
+ .. default-domain:: set
+
+ This class represent a Set in redis.
+ """
def sadd(self, *values):
- """Add the specified members to the Set."""
+ """
+ Add the specified members to the Set.
+
+ :param values: a list of values or a simple value.
+ :rtype: integer representing the number of value added to the set.
+
+ >>> s = Set("test")
+ >>> s.clear()
+ >>> s.add(["1", "2", "3"])
+ 3
+ >>> s.add(["4"])
+ 1
+ >>> print s
+ <Set 'test' set(['1', '3', '2', '4'])>
+ >>> s.clear()
+
+ """
return self.db.sadd(self.key, *_parse_values(values))
def srem(self, *values):
+ """
+ Remove the values from the Set if they are present.
+
+ :param values: a list of values or a simple value.
+ :rtype: boolean indicating if the values have been removed.
+
+ >>> s = Set("test")
+ >>> s.add(["1", "2", "3"])
+ 3
+ >>> s.srem(["1", "3"])
+ True
+ >>> s.clear()
+
+ """
return self.db.srem(self.key, *_parse_values(values))
def spop(self):
- """Remove and return (pop) a random element from the Set."""
- return self.db.spop(self.key)
+ """
+ Remove and return (pop) a random element from the Set.
- def discard(self, *values):
- """Remove element elem from the set if it is present."""
- self.srem(*values)
+ :rtype: String representing the value poped.
+
+ >>> s = Set("test")
+ >>> s.add("1")
+ 1
+ >>> s.spop()
+ '1'
+ >>> s.members
+ set([])
+
+ """
+ return self.db.spop(self.key)
def __repr__(self):
return "<%s '%s' %s>" % (self.__class__.__name__, self.key,
self.members)
def isdisjoint(self, other):
- """Return True if the set has no elements in common with other."""
+ """
+ Return True if the set has no elements in common with other.
+
+ :param other: another ``Set``
+ :rtype: boolean
+
+ >>> s1 = Set("key1")
+ >>> s2 = Set("key2")
+ >>> s1.add(['a', 'b', 'c'])
+ 3
+ >>> s2.add(['c', 'd', 'e'])
+ 3
+ >>> s1.isdisjoint(s2)
+ False
+ >>> s1.clear()
+ >>> s2.clear()
+ """
return not bool(self.db.sinter([self.key, other.key]))
- def issubset(self, other):
- """Test whether every element in the set is in other."""
- return self <= other
+ def issubset(self, other_set):
+ """
+ Test whether every element in the set is in other.
+
+ :param other_set: another ``Set`` to compare to.
- def __le__(self, other):
- return self.db.sinter([self.key, other.key]) == self.all()
+ >>> s1 = Set("key1")
+ >>> s2 = Set("key2")
+ >>> s1.add(['a', 'b', 'c'])
+ 3
+ >>> s2.add('b')
+ 1
+ >>> s2.issubset(s1)
+ True
+ >>> s1.clear()
+ >>> s2.clear()
- def __lt__(self, other):
+ """
+ return self <= other_set
+
+ def __le__(self, other_set):
+ return self.db.sinter([self.key, other_set.key]) == self.all()
+
+ def __lt__(self, other_set):
"""Test whether the set is a true subset of other."""
- return self <= other and self != other
+ return self <= other_set and self != other_set
- def __eq__(self, other):
- if other.key == self.key:
+ def __eq__(self, other_set):
+ """
+ Test equality of:
+ 1. keys
+ 2. members
+ """
+ if other_set.key == self.key:
return True
- slen, olen = len(self), len(other)
+ slen, olen = len(self), len(other_set)
if olen == slen:
- return self.members == other.members
+ return self.members == other_set.members
else:
return False
- def __ne__(self, other):
- return not self.__eq__(other)
+ def __ne__(self, other_set):
+ return not self.__eq__(other_set)
- def issuperset(self, other):
- """Test whether every element in other is in the set."""
- return self >= other
+ def issuperset(self, other_set):
+ """
+ Test whether every element in other is in the set.
+
+ :param other_set: another ``Set`` to compare to.
+
+ >>> s1 = Set("key1")
+ >>> s2 = Set("key2")
+ >>> s1.add(['a', 'b', 'c'])
+ 3
+ >>> s2.add('b')
+ 1
+ >>> s1.issuperset(s2)
+ True
+ >>> s1.clear()
+ >>> s2.clear()
+
+ """
+ return self >= other_set
- def __ge__(self, other):
+ def __ge__(self, other_set):
"""Test whether every element in other is in the set."""
- return self.db.sinter([self.key, other.key]) == other.all()
+ return self.db.sinter([self.key, other_set.key]) == other_set.all()
- def __gt__(self, other):
+ def __gt__(self, other_set):
"""Test whether the set is a true superset of other."""
- return self >= other and self != other
+ return self >= other_set and self != other_set
# SET Operations
- def union(self, key, *others):
+ def union(self, key, *other_sets):
+ """
+ Return a new ``Set`` representing the union of *n* sets.
+
+ :param key: String representing the key where to store the result (the union)
+ :param other_sets: list of other ``Set``.
+ :rtype: ``Set``
+
+ >>> s1 = Set('key1')
+ >>> s2 = Set('key2')
+ >>> s1.add(['a', 'b', 'c'])
+ 3
+ >>> s2.add(['d', 'e'])
+ 2
+ >>> s3 = s1.union('key3', s2)
+ >>> s3.key
+ u'key3'
+ >>> s3.members
+ set(['a', 'c', 'b', 'e', 'd'])
+ >>> s1.clear()
+ >>> s2.clear()
+ >>> s3.clear()
+
+ """
if not isinstance(key, str) and not isinstance(key, unicode):
raise ValueError("Expect a (unicode) string as key")
key = unicode(key)
- """Return a new set with elements from the set and all others."""
- self.db.sunionstore(key, [self.key] + [o.key for o in others])
+
+ self.db.sunionstore(key, [self.key] + [o.key for o in other_sets])
return Set(key)
- def intersection(self, key, *others):
+ def intersection(self, key, *other_sets):
+ """
+ Return a new ``Set`` representing the intersection of *n* sets.
+
+ :param key: String representing the key where to store the result (the union)
+ :param other_sets: list of other ``Set``.
+ :rtype: Set
+
+ >>> s1 = Set('key1')
+ >>> s2 = Set('key2')
+ >>> s1.add(['a', 'b', 'c'])
+ 3
+ >>> s2.add(['c', 'e'])
+ 2
+ >>> s3 = s1.intersection('key3', s2)
+ >>> s3.key
+ u'key3'
+ >>> s3.members
+ set(['c'])
+ >>> s1.clear()
+ >>> s2.clear()
+ >>> s3.clear()
+ """
+
+
if not isinstance(key, str) and not isinstance(key, unicode):
raise ValueError("Expect a (unicode) string as key")
key = unicode(key)
- """Return a new set with elements common to the set and all others."""
- self.db.sinterstore(key, [self.key] + [o.key for o in others])
+
+ self.db.sinterstore(key, [self.key] + [o.key for o in other_sets])
return Set(key)
- def difference(self, key, *others):
+ def difference(self, key, *other_sets):
+ """
+ Return a new ``Set`` representing the difference of *n* sets.
+
+ :param key: String representing the key where to store the result (the union)
+ :param other_sets: list of other ``Set``.
+ :rtype: Set
+
+ >>> s1 = Set('key1')
+ >>> s2 = Set('key2')
+ >>> s1.add(['a', 'b', 'c'])
+ 3
+ >>> s2.add(['c', 'e'])
+ 2
+ >>> s3 = s1.difference('key3', s2)
+ >>> s3.key
+ u'key3'
+ >>> s3.members
+ set(['a', 'b'])
+ >>> s1.clear()
+ >>> s2.clear()
+ >>> s3.clear()
+ """
+
if not isinstance(key, str) and not isinstance(key, unicode):
raise ValueError("Expect a (unicode) string as key")
key = unicode(key)
- """Return a new set with elements in the set that are not in the others."""
- self.db.sdiffstore(key, [self.key] + [o.key for o in others])
+
+ self.db.sdiffstore(key, [self.key] + [o.key for o in other_sets])
return Set(key)
- def update(self, *others):
- """Update the set, adding elements from all others."""
- self.db.sunionstore(self.key, [self.key] + [o.key for o in others])
+ def update(self, *other_sets):
+ """Update the set, adding elements from all other_sets.
+
+ :param other_sets: list of ``Set``
+ :rtype: None
+ """
+ self.db.sunionstore(self.key, [self.key] + [o.key for o in other_sets])
- def __ior__(self, other):
- self.db.sunionstore(self.key, [self.key, other.key])
+ def __ior__(self, other_set):
+ self.db.sunionstore(self.key, [self.key, other_set.key])
return self
- def intersection_update(self, *others):
- """Update the set, keeping only elements found in it and all others."""
- self.db.sinterstore(self.key, [o.key for o in [self.key] + others])
+ def intersection_update(self, *other_sets):
+ """
+ Update the set, keeping only elements found in it and all other_sets.
+
+ :param other_sets: list of ``Set``
+ :rtype: None
+ """
+ self.db.sinterstore(self.key, [o.key for o in [self.key] + other_sets])
- def __iand__(self, other):
- self.db.sinterstore(self.key, [self.key, other.key])
+ def __iand__(self, other_set):
+ self.db.sinterstore(self.key, [self.key, other_set.key])
return self
- def difference_update(self, *others):
- """Update the set, removing elements found in others."""
- self.db.sdiffstore(self.key, [o.key for o in [self.key] + others])
+ def difference_update(self, *other_sets):
+ """
+ Update the set, removing elements found in others.
+
+ :param other_sets: list of ``Set``
+ :rtype: None
+ """
+ self.db.sdiffstore(self.key, [o.key for o in [self.key] + other_sets])
- def __isub__(self, other):
- self.db.sdiffstore(self.key, [self.key, other.key])
+ def __isub__(self, other_set):
+ self.db.sdiffstore(self.key, [self.key, other_set.key])
return self
def all(self):
return self.db.smembers(self.key)
+
members = property(all)
+ """
+ return the real content of the Set.
+ """
def copy(self, key):
- """Copy the set to another key and return the new Set.
+ """
+ Copy the set to another key and return the new Set.
- WARNING: If the key exists, it overwrites it.
+ .. WARNING::
+ If the new key already contains a value, it will be overwritten.
"""
copy = Set(key=key, db=self.db)
copy.clear()
@@ -182,53 +390,90 @@ def __iter__(self):
return self.members.__iter__()
def sinter(self, *other_sets):
- """Performs an intersection between Sets.
+ """
+ Performs an intersection between Sets and return the *RAW* result.
- Returns a set of common members. Uses Redis.sinter.
+ .. NOTE::
+ This function return an actual ``set`` object (from python) and not a ``Set``. See func:``intersection``.
"""
return self.db.sinter([self.key] + [s.key for s in other_sets])
def sunion(self, *other_sets):
- """Union between Sets.
+ """
+ Performs a union between two sets and returns the *RAW* result.
- Returns a set of common members. Uses Redis.sunion.
+ .. NOTE::
+ This function return an actual ``set`` object (from python) and not a ``Set``.
"""
return self.db.sunion([self.key] + [s.key for s in other_sets])
def sdiff(self, *other_sets):
- """Union between Sets.
+ """
+ Performs a difference between two sets and returns the *RAW* result.
+
+ .. NOTE::
+ This function return an actual ``set`` object (from python) and not a ``Set``.
+ See function difference.
- Returns a set of common members. Uses Redis.sdiff.
"""
return self.db.sdiff([self.key] + [s.key for s in other_sets])
def scard(self):
+ """
+ Returns the cardinality of the Set.
+
+ :rtype: String containing the cardinality.
+
+ """
return self.db.scard(self.key)
def sismember(self, value):
- return self.db.sismember(self.key, value)
+ """
+ Return ``True`` if the provided value is in the ``Set``.
- def smembers(self):
- return self.db.smembers(self.key)
+ """
+ return self.db.sismember(self.key, value)
def srandmember(self):
+ """
+ Return a random member of the set.
+
+ >>> s = Set("test")
+ >>> s.add(['a', 'b', 'c'])
+ 3
+ >>> s.srandmember() # doctest: +ELLIPSIS
+ '...'
+ >>> # 'a', 'b' or 'c'
+ """
return self.db.srandmember(self.key)
add = sadd
+ """see sadd"""
pop = spop
+ """see spop"""
remove = srem
+ """see srem"""
__contains__ = sismember
__len__ = scard
class List(Container):
+ """
+ This class represent a list object as seen in redis.
+ """
def all(self):
- """Returns all items in the list."""
+ """
+ Returns all items in the list.
+ """
return self.lrange(0, -1)
members = property(all)
+ """Return all items in the list."""
def llen(self):
+ """
+ Returns the length of the list.
+ """
return self.db.llen(self.key)
__len__ = llen
@@ -246,41 +491,124 @@ def __setitem__(self, index, value):
self.lset(index, value)
def lrange(self, start, stop):
+ """
+ Returns a range of items.
+
+ :param start: integer representing the start index of the range
+ :param stop: integer representing the size of the list.
+
+ >>> l = List("test")
+ >>> l.push(['a', 'b', 'c', 'd'])
+ 4L
+ >>> l.lrange(1, 2)
+ ['b', 'c']
+ >>> l.clear()
+
+ """
return self.db.lrange(self.key, start, stop)
def lpush(self, *values):
+ """
+ Push the value into the list from the *left* side
+
+ :param values: a list of values or single value to push
+ :rtype: long representing the number of values pushed.
+
+ >>> l = List("test")
+ >>> l.lpush(['a', 'b'])
+ 2L
+ >>> l.clear()
+ """
return self.db.lpush(self.key, *_parse_values(values))
def rpush(self, *values):
+ """
+ Push the value into the list from the *right* side
+
+ :param values: a list of values or single value to push
+ :rtype: long representing the size of the list.
+
+ >>> l = List("test")
+ >>> l.lpush(['a', 'b'])
+ 2L
+ >>> l.rpush(['c', 'd'])
+ 4L
+ >>> l.members
+ ['b', 'a', 'c', 'd']
+ >>> l.clear()
+ """
+
return self.db.rpush(self.key, *_parse_values(values))
def extend(self, iterable):
- """Extend list by appending elements from the iterable."""
+ """
+ Extend list by appending elements from the iterable.
+
+ :param iterable: an iterable objects.
+ """
self.rpush(*[e for e in iterable])
def count(self, value):
- """Return number of occurrences of value."""
+ """
+ Return number of occurrences of value.
+
+ :param value: a value tha *may* be contained in the list
+ """
return self.members.count(value)
def lpop(self):
+ """
+ Pop the first object from the left.
+
+ :return: the popped value.
+
+ """
return self.db.lpop(self.key)
def rpop(self):
+ """
+ Pop the first object from the right.
+
+ :return: the popped value.
+ """
return self.db.rpop(self.key)
def rpoplpush(self, key):
"""
Remove an element from the list,
atomically add it to the head of the list indicated by key
+
+ :param key: the key of the list receiving the popped value.
+ :return: the popped (and pushed) value
+
+ >>> l = List('list1')
+ >>> l.push(['a', 'b', 'c'])
+ 3L
+ >>> l.rpoplpush('list2')
+ 'c'
+ >>> l2 = List('list2')
+ >>> l2.members
+ ['c']
+ >>> l.clear()
+ >>> l2.clear()
+
"""
return self.db.rpoplpush(self.key, key)
def lrem(self, value, num=1):
- """Remove first occurrence of value."""
+ """
+ Remove first occurrence of value.
+
+ :return: 1 if the value has been removed, 0 otherwise
+ """
return self.db.lrem(self.key, value, num)
def reverse(self):
- """Reverse in place."""
+ """
+ Reverse the list in place.
+
+ :return: None
+ """
r = self[:]
r.reverse()
self.clear()
@@ -289,22 +617,48 @@ def reverse(self):
def copy(self, key):
"""Copy the list to a new list.
- WARNING: If key exists, it clears it before copying.
+ ..WARNING:
+ If destination key already contains a value, it clears it before copying.
"""
copy = List(key, self.db)
copy.clear()
copy.extend(self)
return copy
def ltrim(self, start, end):
- """Trim the list from start to end."""
+ """
+ Trim the list from start to end.
+
+ :return: None
+ """
return self.db.ltrim(self.key, start, end)
- def lindex(self, value):
- return self.db.lindex(self.key, value)
+ def lindex(self, idx):
+ """
+ Return the value at the index *idx*
+
+ :param idx: the index to fetch the value.
+ :return: the value or None if out of range.
+ """
+ return self.db.lindex(self.key, idx)
+
+ def lset(self, idx, value=0):
+ """
+ Set the value in the list at index *idx*
+
+ :return: True is the operation succeed.
+
+ >>> l = List('test')
+ >>> l.push(['a', 'b', 'c'])
+ 3L
+ >>> l.lset(0, 'e')
+ True
+ >>> l.members
+ ['e', 'b', 'c']
+ >>> l.clear()
- def lset(self, index, value=0):
- return self.db.lset(self.key, index, value)
+ """
+ return self.db.lset(self.key, idx, value)
def __iter__(self):
return self.members.__iter__()
@@ -410,6 +764,11 @@ def __repr__(self):
return repr(self.typecast_iter(self.list))
class SortedSet(Container):
+ """
+ This class represents a SortedSet in redis.
+ Use it if you want to arrange your set in any order.
+
+ """
def __getitem__(self, index):
if isinstance(index, slice):
@@ -418,20 +777,26 @@ def __getitem__(self, index):
return self.zrange(index, index)[0]
def score(self, member):
- """Returns the score of member."""
+ """
+ Returns the score of member.
+ """
return self.zscore(member)
def __contains__(self, val):
return self.zscore(val) is not None
@property
def members(self):
- """Returns the members of the set."""
+ """
+ Returns the members of the set.
+ """
return self.zrange(0, -1)
@property
def revmembers(self):
- """Returns the members of the set in reverse."""
+ """
+ Returns the members of the set in reverse.
+ """
return self.zrevrange(0, -1)
def __iter__(self):
@@ -442,33 +807,50 @@ def __reversed__(self):
def __repr__(self):
return "<%s '%s' %s>" % (self.__class__.__name__, self.key,
- self.members)
+ self.members)
@property
def _min_score(self):
+ """
+ Returns the minimum score in the SortedSet.
+ """
return self.zscore(self.__getitem__(0))
@property
def _max_score(self):
+ """
+ Returns the maximum score in the SortedSet.
+ """
return self.zscore(self.__getitem__(-1))
def lt(self, v, limit=None, offset=None):
- """Returns the list of the members of the set that have scores
+ """
+ Returns the list of the members of the set that have scores
less than v.
+
+ :param v: the score to compare to.
+ :param limit: limit the result to *n* elements
+ :param offset: Skip the first *n* elements
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore(self._min_score, "(%f" % v,
- start=offset, num=limit)
+ start=offset, num=limit)
def le(self, v, limit=None, offset=None):
- """Returns the list of the members of the set that have scores
+ """
+ Returns the list of the members of the set that have scores
less than or equal to v.
+
+ :param v: the score to compare to.
+ :param limit: limit the result to *n* elements
+ :param offset: Skip the first *n* elements
+
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore(self._min_score, v,
- start=offset, num=limit)
+ start=offset, num=limit)
def gt(self, v, limit=None, offset=None):
"""Returns the list of the members of the set that have scores
@@ -477,29 +859,67 @@ def gt(self, v, limit=None, offset=None):
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore("(%f" % v, self._max_score,
- start=offset, num=limit)
+ start=offset, num=limit)
def ge(self, v, limit=None, offset=None):
"""Returns the list of the members of the set that have scores
greater than or equal to v.
+
+ :param v: the score to compare to.
+ :param limit: limit the result to *n* elements
+ :param offset: Skip the first *n* elements
+
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore("(%f" % v, self._max_score,
- start=offset, num=limit)
+ start=offset, num=limit)
def between(self, min, max, limit=None, offset=None):
- """Returns the list of the members of the set that have scores
+ """
+ Returns the list of the members of the set that have scores
between min and max.
+
+ .. Note::
+ The min and max are inclusive when comparing the values.
+
+ :param min: the minimum score to compare to.
+ :param max: the maximum score to compare to.
+ :param limit: limit the result to *n* elements
+ :param offset: Skip the first *n* elements
+
+ >>> s = SortedSet("foo")
+ >>> s.add('a', 10)
+ 1
+ >>> s.add('b', 20)
+ 1
+ >>> s.add('c', 30)
+ 1
+ >>> s.between(20, 30)
+ ['b', 'c']
+ >>> s.clear()
"""
if limit is not None and offset is None:
offset = 0
return self.zrangebyscore(min, max,
- start=offset, num=limit)
+ start=offset, num=limit)
def zadd(self, members, score=1):
+ """
+ Add members in the set and assign them the score.
+
+ :param members: a list of item or a single item
+ :param score: the score the assign to the item(s)
+
+ >>> s = SortedSet("foo")
+ >>> s.add('a', 10)
+ 1
+ >>> s.add('b', 20)
+ 1
+ >>> s.clear()
+ """
_members = []
- if type(members) != type({}):
+ if not isinstance(members, dict):
_members = [members, score]
else:
for member, score in members.items():
@@ -508,39 +928,206 @@ def zadd(self, members, score=1):
return self.db.zadd(self.key, *_members)
def zrem(self, *values):
+ """
+ Remove the values from the SortedSet
+
+ :return: True if **at least one** value is successfully
+ removed, False otherwise
+
+ >>> s = SortedSet('foo')
+ >>> s.add('a', 10)
+ 1
+ >>> s.zrem('a')
+ True
+ >>> s.members
+ []
+ >>> s.clear()
+ """
return self.db.zrem(self.key, *_parse_values(values))
def zincrby(self, att, value=1):
- return self.db.zincrby(self.key, value, att)
+ """
+ Increment the score of the item by ``value``
+
+ :param att: the member to increment
+ :param value: the value to add to the current score
+ :returns: the new score of the member
+
+ >>> s = SortedSet("foo")
+ >>> s.add('a', 10)
+ 1
+ >>> s.zincrby("a", 10)
+ 20.0
+ >>> s.clear()
+ """
+ return self.db.zincrby(self.key, att, value)
def zrevrank(self, member):
+ """
+ Returns the ranking in reverse order for the member
+
+ >>> s = SortedSet("foo")
+ >>> s.add('a', 10)
+ 1
+ >>> s.add('b', 20)
+ 1
+ >>> s.revrank('a')
+ 1
+ >>> s.clear()
+ """
return self.db.zrevrank(self.key, member)
def zrange(self, start, stop, withscores=False):
+ """
+ Returns all the elements including between ``start`` (non included) and
+ ``stop`` (included).
+
+ :param withscore: True if the score of the elements should
+ also be returned
+
+ >>> s = SortedSet("foo")
+ >>> s.add('a', 10)
+ 1
+ >>> s.add('b', 20)
+ 1
+ >>> s.add('c', 30)
+ 1
+ >>> s.zrange(1, 3)
+ ['b', 'c']
+ >>> s.zrange(1, 3, withscores=True)
+ [('b', 20.0), ('c', 30.0)]
+ >>> s.clear()
+ """
return self.db.zrange(self.key, start, stop, withscores=withscores)
def zrevrange(self, start, end, **kwargs):
+ """
+ Returns the range of items included between ``start`` and ``stop``
+ in reverse order (from high to low)
+
+ >>> s = SortedSet("foo")
+ >>> s.add('a', 10)
+ 1
+ >>> s.add('b', 20)
+ 1
+ >>> s.add('c', 30)
+ 1
+ >>> s.zrevrange(1, 2)
+ ['b', 'a']
+ >>> s.clear()
+ """
return self.db.zrevrange(self.key, start, end, **kwargs)
def zrangebyscore(self, min, max, **kwargs):
+ """
+ Returns the range of elements included between the scores (min and max)
+
+ >>> s = SortedSet("foo")
+ >>> s.add('a', 10)
+ 1
+ >>> s.add('b', 20)
+ 1
+ >>> s.add('c', 30)
+ 1
+ >>> s.zrangebyscore(20, 30)
+ ['b', 'c']
+ >>> s.clear()
+ """
return self.db.zrangebyscore(self.key, min, max, **kwargs)
def zcard(self):
+ """
+ Returns the cardinality of the SortedSet.
+
+ >>> s = SortedSet("foo")
+ >>> s.add("a", 1)
+ 1
+ >>> s.add("b", 2)
+ 1
+ >>> s.add("c", 3)
+ 1
+ >>> s.zcard()
+ 3
+ >>> s.clear()
+ """
return self.db.zcard(self.key)
- def zscore(self, value):
- return self.db.zscore(self.key, value)
+ def zscore(self, elem):
+ """
+ Return the score of an element
+
+ >>> s = SortedSet("foo")
+ >>> s.add("a", 10)
+ 1
+ >>> s.score("a")
+ 10.0
+ >>> s.clear()
+ """
+ return self.db.zscore(self.key, elem)
def zremrangebyrank(self, start, stop):
+ """
+ Remove a range of element between the rank ``start`` and
+ ``stop`` both included.
+
+ :return: the number of item deleted
+
+ >>> s = SortedSet("foo")
+ >>> s.add("a", 10)
+ 1
+ >>> s.add("b", 20)
+ 1
+ >>> s.add("c", 30)
+ 1
+ >>> s.zremrangebyrank(1, 2)
+ 2
+ >>> s.members
+ ['a']
+ >>> s.clear()
+ """
return self.db.zremrangebyrank(self.key, start, stop)
def zremrangebyscore(self, min_value, max_value):
+ """
+ Remove a range of element by between score ``min_value`` and
+ ``max_value`` both included.
+
+ :returns: the number of items deleted.
+
+ >>> s = SortedSet("foo")
+ >>> s.add("a", 10)
+ 1
+ >>> s.add("b", 20)
+ 1
+ >>> s.add("c", 30)
+ 1
+ >>> s.zremrangebyscore(10, 20)
+ 2
+ >>> s.members
+ ['c']
+ >>> s.clear()
+ """
+
return self.db.zremrangebyscore(self.key, min_value, max_value)
- def zrank(self, value):
- return self.db.zrank(self.key, value)
+ def zrank(self, elem):
+ """
+ Returns the rank of the element.
+
+ >>> s = SortedSet("foo")
+ >>> s.add("a", 10)
+ 1
+ >>> s.zrank("a")
+ 0
+ >>> s.clear()
+ """
+ return self.db.zrank(self.key, elem)
+
def eq(self, value):
+ """
+ Returns the elements that have ``value`` for score.
+ """
return self.zrangebyscore(value, value)
__len__ = zcard
@@ -573,44 +1160,109 @@ def __iter__(self):
return self.hgetall().__iter__()
def __repr__(self):
- return "<%s '%s' %s>" % (self.__class__.__name__, self.key, self.hgetall())
+ return "<%s '%s' %s>" % (self.__class__.__name__,
+ self.key, self.hgetall())
def _set_dict(self, new_dict):
self.clear()
self.update(new_dict)
def hlen(self):
+ """
+ Returns the number of elements in the Hash.
+ """
return self.db.hlen(self.key)
def hset(self, member, value):
+ """
+ Set ``member`` in the Hash at ``value``.
+
+ :returns: 1 if member is a new field and the value has been
+ stored, 0 if the field existed and the value has been
+ updated.
+
+ >>> h = Hash("foo")
+ >>> h.hset("bar", "value")
+ 1L
+ >>> h.clear()
+ """
return self.db.hset(self.key, member, value)
def hdel(self, *members):
+ """
+ Delete one or more hash field.
+
+ :param members: on or more fields to remove.
+ :return: the number of fields that were removed
+
+ >>> h = Hash("foo")
+ >>> h.hset("bar", "value")
+ 1L
+ >>> h.hdel("bar")
+ True
+ >>> h.clear()
+ """
return self.db.hdel(self.key, *_parse_values(members))
def hkeys(self):
+ """
+ Returns all fields name in the Hash
+ """
return self.db.hkeys(self.key)
def hgetall(self):
+ """
+ Returns all the fields and values in the Hash.
+
+ :rtype: dict
+ """
return self.db.hgetall(self.key)
def hvals(self):
+ """
+ Returns all the values in the Hash
+
+ :rtype: list
+ """
return self.db.hvals(self.key)
def hget(self, field):
+ """
+ Returns the value stored in the field, None if the field doesn't exist.
+ """
return self.db.hget(self.key, field)
def hexists(self, field):
+ """
+ Returns ``True`` if the field exists, ``False`` otherwise.
+ """
return self.db.hexists(self.key, field)
def hincrby(self, field, increment=1):
+ """
+ Increment the value of the field.
+ :returns: the value of the field after incrementation
+
+ >>> h = Hash("foo")
+ >>> h.hincrby("bar", 10)
+ 10L
+ >>> h.hincrby("bar", 2)
+ 12L
+ >>> h.clear()
+ """
return self.db.hincrby(self.key, field, increment)
def hmget(self, fields):
+ """
+ Returns the values stored in the fields.
+ """
return self.db.hmget(self.key, fields)
def hmset(self, mapping):
"""
+ Sets or updates the fields with their corresponding values.
+
+ :param mapping: a dict with keys and values
"""
return self.db.hmset(self.key, mapping)
View
8 tests/containers.py
@@ -21,9 +21,9 @@ def test_common_operations(self):
self.assertEqual(set(['apples', 'oranges', 'bananas', 'tomatoes', 'strawberries', 'blackberries']), fruits.all())
# remove
- fruits.discard('apples')
- fruits.discard('bananas', 'blackberries')
- fruits.discard(['tomatoes', 'strawberries'])
+ fruits.remove('apples')
+ fruits.remove('bananas', 'blackberries')
+ fruits.remove(['tomatoes', 'strawberries'])
self.assertEqual(set(['oranges']), fruits.all())
@@ -161,7 +161,7 @@ def test_access_redis_methods(self):
s.srem('b')
self.assertEqual('a', s.spop())
s.sadd('a')
- self.assert_('a' in s.smembers())
+ self.assert_('a' in s.members)
s.sadd('b')
self.assertEqual(2, s.scard())
self.assert_(s.sismember('a'))

0 comments on commit 56e4258

Please sign in to comment.