diff options
| author | bwarsaw | 2007-05-28 20:21:41 +0000 |
|---|---|---|
| committer | bwarsaw | 2007-05-28 20:21:41 +0000 |
| commit | b18f632faa6de17badabb3c6c7ba61752ac84c37 (patch) | |
| tree | 8b444330b288c5dfc9b25be639d429abfaeb3d3d /Mailman/testing/test_enum.py | |
| parent | 5ff792b13599920527b48f92f8bad880668f8f26 (diff) | |
| download | mailman-b18f632faa6de17badabb3c6c7ba61752ac84c37.tar.gz mailman-b18f632faa6de17badabb3c6c7ba61752ac84c37.tar.zst mailman-b18f632faa6de17badabb3c6c7ba61752ac84c37.zip | |
Merge exp-elixir-branch to trunk. There is enough working to make me feel
confident the Elixir branch is ready to become mainline. Also, fewer branches
makes for an easier migration to a dvcs.
Don't expect much of the old test suite to work, or even for much of the old
functionality to work. The changes here are disruptive enough to break higher
level parts of Mailman. But that's okay because I am slowly building up a new
and improved test suite, which will lead to a functional system again.
For now, only the doctests in Mailman/docs (and their related test harnesses)
will pass, but they all do pass. Note that Mailman/docs serve as system
documentation first and unit tests second. You should be able to read the
doctest files to understand the underlying data model.
Other changes included in this merge:
- Added the Mailman.ext extension package.
- zope.interfaces uses to describe major components
- SQLAlchemy/Elixir used as the database model
- Top level doinstall target renamed to justinstall
- 3rd-party packages are now installed in pythonlib/lib/python to be more
compliant with distutils standards. This allows us to use just --home
instead of all the --install-* options.
- No longer need to include the email package or pysqlite, as Python 2.5 is
required (and comes with both packages).
- munepy package is included, for Python enums
- IRosterSets are added as a way to manage a collection of IRosters. Roster
sets are named so that we can maintain the indirection between mailing lists
and rosters, where the two are maintained in different storages.
- IMailingListRosters: remove_*_roster() -> delete_*_roster()
- Remove IMember interface.
- Utils.list_names() -> config.list_manager.names
- fqdn_listname() takes an optional hostname argument.
- Added a bunch of new exceptions used throughout the new interfaces.
- Make LockFile a context manager for use with the 'with' statement.
Diffstat (limited to 'Mailman/testing/test_enum.py')
| -rw-r--r-- | Mailman/testing/test_enum.py | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/Mailman/testing/test_enum.py b/Mailman/testing/test_enum.py deleted file mode 100644 index a8c389bb4..000000000 --- a/Mailman/testing/test_enum.py +++ /dev/null @@ -1,125 +0,0 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. - -"""Unit tests for Enums.""" - -import operator -import unittest - -from Mailman.enum import Enum - - - -class Colors(Enum): - red = 1 - green = 2 - blue = 3 - - -class MoreColors(Colors): - pink = 4 - cyan = 5 - - -class OtherColors(Enum): - red = 1 - blue = 2 - yellow = 3 - - - -class TestEnum(unittest.TestCase): - def test_enum_basics(self): - unless = self.failUnless - raises = self.assertRaises - # Cannot compare by equality - raises(NotImplementedError, operator.eq, Colors.red, Colors.red) - raises(NotImplementedError, operator.ne, Colors.red, Colors.red) - raises(NotImplementedError, operator.lt, Colors.red, Colors.red) - raises(NotImplementedError, operator.gt, Colors.red, Colors.red) - raises(NotImplementedError, operator.le, Colors.red, Colors.red) - raises(NotImplementedError, operator.ge, Colors.red, Colors.red) - raises(NotImplementedError, operator.eq, Colors.red, 1) - raises(NotImplementedError, operator.ne, Colors.red, 1) - raises(NotImplementedError, operator.lt, Colors.red, 1) - raises(NotImplementedError, operator.gt, Colors.red, 1) - raises(NotImplementedError, operator.le, Colors.red, 1) - raises(NotImplementedError, operator.ge, Colors.red, 1) - # Comparison by identity - unless(Colors.red is Colors.red) - unless(Colors.red is MoreColors.red) - unless(Colors.red is not OtherColors.red) - unless(Colors.red is not Colors.blue) - - def test_enum_conversions(self): - eq = self.assertEqual - unless = self.failUnless - raises = self.assertRaises - unless(Colors.red is Colors['red']) - unless(Colors.red is Colors[1]) - unless(Colors.red is Colors('red')) - unless(Colors.red is Colors(1)) - unless(Colors.red is not Colors['blue']) - unless(Colors.red is not Colors[2]) - unless(Colors.red is not Colors('blue')) - unless(Colors.red is not Colors(2)) - unless(Colors.red is MoreColors['red']) - unless(Colors.red is MoreColors[1]) - unless(Colors.red is MoreColors('red')) - unless(Colors.red is MoreColors(1)) - unless(Colors.red is not OtherColors['red']) - unless(Colors.red is not OtherColors[1]) - unless(Colors.red is not OtherColors('red')) - unless(Colors.red is not OtherColors(1)) - raises(ValueError, Colors.__getitem__, 'magenta') - raises(ValueError, Colors.__getitem__, 99) - raises(ValueError, Colors.__call__, 'magenta') - raises(ValueError, Colors.__call__, 99) - eq(int(Colors.red), 1) - eq(int(Colors.blue), 3) - eq(int(MoreColors.red), 1) - eq(int(OtherColors.blue), 2) - - def test_enum_duplicates(self): - try: - # This is bad because kyle and kenny have the same integer value. - class Bad(Enum): - cartman = 1 - stan = 2 - kyle = 3 - kenny = 3 - butters = 4 - except TypeError: - got_error = True - else: - got_error = False - self.failUnless(got_error) - - def test_enum_iteration(self): - eq = self.assertEqual - # Iteration sorts on the int value of the enum - values = [str(v) for v in MoreColors] - eq(values, ['red', 'green', 'blue', 'pink', 'cyan']) - values = [int(v) for v in MoreColors] - eq(values, [1, 2, 3, 4, 5]) - - - -def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestEnum)) - return suite |
