__version__ = '$Id$'

from tests.utils import unittest
from pywikibot import date


class TestDate(unittest.TestCase):
    """Test cases for date library"""

    def __init__(self, formatname):
        super(TestDate, self).__init__()
        self.formatname = formatname

    def testMapEntry(self, formatname):
        """The test ported from date.py"""
        step = 1
        if formatname in date.decadeFormats:
            step = 10
        predicate, start, stop = date.formatLimits[formatname]

        for code, convFunc in date.formats[formatname].items():
            for value in range(start, stop, step):
                self.assertTrue(
                    predicate(value),
                    "date.formats['%(formatname)s']['%(code)s']:\n"
                    "invalid value %(value)d" % locals())

                newValue = convFunc(convFunc(value))
                self.assertEqual(
                    newValue, value,
                    "date.formats['%(formatname)s']['%(code)s']:\n"
                    "value %(newValue)d does not match %(value)s"
                    % locals())

    def runTest(self):
        """method called by unittest"""
        self.testMapEntry(self.formatname)


def suite():
    """Setup the test suite and register all test to different instances"""
    suite = unittest.TestSuite()
    suite.addTests(TestDate(formatname) for formatname in date.formats)
    return suite


if __name__ == '__main__':
    try:
        unittest.TextTestRunner().run(suite())
    except SystemExit:
        pass

__version__ = '$Id$'

from tests.utils import unittest
from pywikibot import date


class TestDate(unittest.TestCase):
    """Test cases for date library"""

    def testMapEntry(self):
        """Test the validity of the pywikibot.date format maps."""
        for formatName in date.formats:
            step = 1
            if formatName in date.decadeFormats:
                step = 10
            predicate, start, stop = date.formatLimits[formatName]

            for code, convFunc in date.formats[formatName].items():
                for value in range(start, stop, step):
                    self.assertTrue(
                        predicate(value),
                        "date.formats['%(formatName)s']['%(code)s']:\n"
                        "invalid value %(value)d" % locals())

                    newValue = convFunc(convFunc(value))
                    self.assertEqual(
                        newValue, value,
                        "date.formats['%(formatName)s']['%(code)s']:\n"
                        "value %(newValue)d does not match %(value)s"
                        % locals())


if __name__ == '__main__':
    try:
        unittest.main()
    except SystemExit:
        pass

Revert "Progressing dots to show test is running"
Revert "Progressing dots to show test is running"

Breaks tests; https://travis-ci.org/wikimedia/pywikibot-core/builds/26752150

This reverts commit 93379dbf499c58438917728b74862f282c15dba4.

Change-Id: Iacb4cc9e6999d265b46c558ed3999c1198f87de0

  __version__ = '$Id$'
  
  from tests.utils import unittest
  from pywikibot import date
  
  
  class TestDate(unittest.TestCase):
      """Test cases for date library"""
  
-     def __init__(self, formatname):
-         super(TestDate, self).__init__()
-         self.formatname = formatname
+     def testMapEntry(self):
+         """Test the validity of the pywikibot.date format maps."""
+         for formatName in date.formats:
+             step = 1
+             if formatName in date.decadeFormats:
+                 step = 10
+             predicate, start, stop = date.formatLimits[formatName]
  
-     def testMapEntry(self, formatname):
-         """The test ported from date.py"""
-         step = 1
-         if formatname in date.decadeFormats:
-             step = 10
-         predicate, start, stop = date.formatLimits[formatname]
+             for code, convFunc in date.formats[formatName].items():
+                 for value in range(start, stop, step):
+                     self.assertTrue(
+                         predicate(value),
+                         "date.formats['%(formatName)s']['%(code)s']:\n"
+                         "invalid value %(value)d" % locals())
  
-         for code, convFunc in date.formats[formatname].items():
-             for value in range(start, stop, step):
-                 self.assertTrue(
-                     predicate(value),
-                     "date.formats['%(formatname)s']['%(code)s']:\n"
-                     "invalid value %(value)d" % locals())
- 
-                 newValue = convFunc(convFunc(value))
+                     newValue = convFunc(convFunc(value))
-                 self.assertEqual(
+                     self.assertEqual(
-                     newValue, value,
+                         newValue, value,
-                     "date.formats['%(formatname)s']['%(code)s']:\n"
+                         "date.formats['%(formatName)s']['%(code)s']:\n"
-                     "value %(newValue)d does not match %(value)s"
+                         "value %(newValue)d does not match %(value)s"
-                     % locals())
+                         % locals())
- 
-     def runTest(self):
-         """method called by unittest"""
-         self.testMapEntry(self.formatname)
- 
- 
- def suite():
-     """Setup the test suite and register all test to different instances"""
-     suite = unittest.TestSuite()
-     suite.addTests(TestDate(formatname) for formatname in date.formats)
-     return suite
  
  
  if __name__ == '__main__':
      try:
-         unittest.TextTestRunner().run(suite())
+         unittest.main()
      except SystemExit:
          pass
  
Revert "Progressing dots to show test is running"
## Code Before:
__version__ = '$Id$'

from tests.utils import unittest
from pywikibot import date


class TestDate(unittest.TestCase):
    """Test cases for date library"""

    def __init__(self, formatname):
        super(TestDate, self).__init__()
        self.formatname = formatname

    def testMapEntry(self, formatname):
        """The test ported from date.py"""
        step = 1
        if formatname in date.decadeFormats:
            step = 10
        predicate, start, stop = date.formatLimits[formatname]

        for code, convFunc in date.formats[formatname].items():
            for value in range(start, stop, step):
                self.assertTrue(
                    predicate(value),
                    "date.formats['%(formatname)s']['%(code)s']:\n"
                    "invalid value %(value)d" % locals())

                newValue = convFunc(convFunc(value))
                self.assertEqual(
                    newValue, value,
                    "date.formats['%(formatname)s']['%(code)s']:\n"
                    "value %(newValue)d does not match %(value)s"
                    % locals())

    def runTest(self):
        """method called by unittest"""
        self.testMapEntry(self.formatname)


def suite():
    """Setup the test suite and register all test to different instances"""
    suite = unittest.TestSuite()
    suite.addTests(TestDate(formatname) for formatname in date.formats)
    return suite


if __name__ == '__main__':
    try:
        unittest.TextTestRunner().run(suite())
    except SystemExit:
        pass

## Instruction:
Revert "Progressing dots to show test is running"
## Code After:
__version__ = '$Id$'

from tests.utils import unittest
from pywikibot import date


class TestDate(unittest.TestCase):
    """Test cases for date library"""

    def testMapEntry(self):
        """Test the validity of the pywikibot.date format maps."""
        for formatName in date.formats:
            step = 1
            if formatName in date.decadeFormats:
                step = 10
            predicate, start, stop = date.formatLimits[formatName]

            for code, convFunc in date.formats[formatName].items():
                for value in range(start, stop, step):
                    self.assertTrue(
                        predicate(value),
                        "date.formats['%(formatName)s']['%(code)s']:\n"
                        "invalid value %(value)d" % locals())

                    newValue = convFunc(convFunc(value))
                    self.assertEqual(
                        newValue, value,
                        "date.formats['%(formatName)s']['%(code)s']:\n"
                        "value %(newValue)d does not match %(value)s"
                        % locals())


if __name__ == '__main__':
    try:
        unittest.main()
    except SystemExit:
        pass
