* src/gen/lib/date.py: refer to Config values via Config.get()
* src/gen/lib/test/date_test.py: set Config values before testing 2007-11-25 Douglas S. Blank <dblank@cs.brynmawr.edu> svn: r9402
This commit is contained in:
parent
0e82517d94
commit
5fdffbe292
@ -1,3 +1,7 @@
|
||||
2007-11-25 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||
* src/gen/lib/date.py: refer to Config values via Config.get()
|
||||
* src/gen/lib/test/date_test.py: set Config values before testing
|
||||
|
||||
2007-11-25 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||
* src/Config/_GrampsGconfKeys.py: fixed changes in gconf interface
|
||||
|
||||
|
@ -54,24 +54,7 @@ log = logging.getLogger(".Date")
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gen.lib.calendar import *
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
#obtain the ranges once, they do not change!
|
||||
try:
|
||||
import Config
|
||||
_DATE_BEFORE_RANGE = Config.get(Config.DATE_BEFORE_RANGE)
|
||||
_DATE_AFTER_RANGE = Config.get(Config.DATE_AFTER_RANGE)
|
||||
_DATE_ABOUT_RANGE = Config.get(Config.DATE_ABOUT_RANGE)
|
||||
except ImportError:
|
||||
# gen.lib used as module not part of GRAMPS
|
||||
_DATE_BEFORE_RANGE = 9999
|
||||
_DATE_AFTER_RANGE = 9999
|
||||
_DATE_ABOUT_RANGE = 10
|
||||
import Config
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -291,15 +274,15 @@ class Date:
|
||||
# if BEFORE, AFTER, or ABOUT/EST, adjust:
|
||||
if self.modifier == Date.MOD_BEFORE:
|
||||
stopmax = date_offset(startmin, -1)
|
||||
fdiff = _DATE_BEFORE_RANGE
|
||||
fdiff = Config.get(Config.DATE_BEFORE_RANGE)
|
||||
startmin = (stopmax[0] - fdiff, stopmax[1], stopmax[2])
|
||||
elif self.modifier == Date.MOD_AFTER:
|
||||
startmin = date_offset(stopmax, 1)
|
||||
fdiff = _DATE_AFTER_RANGE
|
||||
fdiff = Config.get(Config.DATE_AFTER_RANGE)
|
||||
stopmax = (startmin[0] + fdiff, startmin[1], startmin[2])
|
||||
elif (self.modifier == Date.MOD_ABOUT or
|
||||
self.quality == Date.QUAL_ESTIMATED):
|
||||
fdiff = _DATE_ABOUT_RANGE
|
||||
fdiff = Config.get(Config.DATE_ABOUT_RANGE)
|
||||
startmin = (startmin[0] - fdiff, startmin[1], startmin[2])
|
||||
stopmax = (stopmax[0] + fdiff, stopmax[1], stopmax[2])
|
||||
# return tuples not lists, for comparisons
|
||||
|
@ -29,6 +29,7 @@ import unittest
|
||||
from test import test_util
|
||||
test_util.path_append_parent()
|
||||
|
||||
import Config
|
||||
import date
|
||||
from DateHandler import parser as df
|
||||
|
||||
@ -124,6 +125,9 @@ if __name__ == "__main__":
|
||||
"before 14 Thermidor 190 (French Republican)", False),
|
||||
("ab cd", "54 ab cd 2000", True, False),
|
||||
]
|
||||
Config.set(Config.DATE_BEFORE_RANGE, 9999)
|
||||
Config.set(Config.DATE_AFTER_RANGE, 9999)
|
||||
Config.set(Config.DATE_ABOUT_RANGE, 10)
|
||||
suite = unittest.TestSuite()
|
||||
count = 1
|
||||
for test in tests:
|
||||
|
Loading…
Reference in New Issue
Block a user