Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from evdb/master
Django 1.3 compat
- Loading branch information
Showing
10 changed files
with
840 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
*.pyc |
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,75 @@ | |||
import os | |||
os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings' | |||
|
|||
from fields import ApproximateDate | |||
import unittest | |||
|
|||
|
|||
class CompareDates(unittest.TestCase): | |||
|
|||
def test_compare(self): | |||
|
|||
y_past = ApproximateDate( year=2000 ); | |||
y_future = ApproximateDate( year=2100 ); | |||
future = ApproximateDate( future=True ); | |||
|
|||
# check that we can be compared to None, '' and u'' | |||
for bad_val in ( '', u'', None ): | |||
self.assertFalse( y_past in ( bad_val, ) ) | |||
self.assertFalse( y_past == bad_val ) | |||
self.assertTrue( y_past != bad_val ) | |||
|
|||
# sanity check | |||
self.assertTrue( y_past == y_past ) | |||
self.assertTrue( y_future == y_future ) | |||
|
|||
self.assertFalse( y_past != y_past ) | |||
self.assertFalse( y_future != y_future ) | |||
|
|||
self.assertTrue( y_past != y_future ) | |||
self.assertTrue( y_future != y_past ) | |||
|
|||
self.assertTrue( y_future > y_past ) | |||
self.assertTrue( y_future >= y_past ) | |||
self.assertFalse( y_past > y_future ) | |||
self.assertFalse( y_past >= y_future ) | |||
|
|||
self.assertTrue( y_past < y_future ) | |||
self.assertTrue( y_past <= y_future ) | |||
self.assertFalse( y_future < y_past ) | |||
self.assertFalse( y_future <= y_past ) | |||
|
|||
# Future dates are always greater | |||
self.assertTrue( y_past < future ) | |||
self.assertTrue( y_past <= future ) | |||
self.assertTrue( y_future < future ) | |||
self.assertTrue( y_future <= future ) | |||
|
|||
self.assertTrue( future > y_past ) | |||
self.assertTrue( future >= y_past ) | |||
self.assertTrue( future > y_future ) | |||
self.assertTrue( future >= y_future ) | |||
|
|||
# Future dates are equal to themselves (so that sorting is sane) | |||
self.assertFalse( future < future ) | |||
self.assertTrue( future <= future ) | |||
self.assertTrue( future == future ) | |||
self.assertTrue( future >= future ) | |||
self.assertFalse( future > future ) | |||
|
|||
|
|||
class Lengths(unittest.TestCase): | |||
known_lengths = ( | |||
({ 'year':1999, }, 10 ), | |||
({ 'year':1999, 'month': 01, }, 10 ), | |||
({ 'year':1999, 'month': 01, 'day': 01 }, 10 ), | |||
({ 'future': True }, 6 ), | |||
); | |||
|
|||
def test_length(self): | |||
for kwargs, length in self.known_lengths: | |||
approx = ApproximateDate( **kwargs ) | |||
self.assertEqual( len( approx ), length ) | |||
|
|||
if __name__ == "__main__": | |||
unittest.main() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1 +1 @@ | |||
../../fields.py | ../../django_date_extensions/fields.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1 +1 @@ | |||
../../widgets.py | ../../django_date_extensions/widgets.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
from distutils.core import setup | |||
|
|||
setup( | |||
name='django_date_extensions', | |||
version='0.1dev', | |||
packages=['django_date_extensions',], | |||
license='GNU Affero General Public license', | |||
long_description=open('README.txt').read(), | |||
) |