-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests fail in March #215
Comments
Thank you for reporting, I am personally grateful for this observation since it identifies a few issues that I need to fix in the new test suite for v3.0 (#199). The assertion checks that there is not more than a 5% variation between the targeted time and the output, in this case your test shows 6.7%. Over the span of 1.4 months, that represents a difference of 2.8 days. I believe that this is a bug in the test case rather than in parsedatetime. The test assertion uses the following logic to calculate months:
Whereas The 5% rule for deltas is problematic, that can represent a huge variation from expectation when the range is months or years. Fortunately the new test suite uses different logic for deltas and as a result this test passes (once I fixed the few minor issues that this case exposed). To help determine whether there is actually a bug in parsedatetime, here is a comparison between 2016 and 2017:
|
Is there a way a fix for this can be prioritized? I work at EFF where I'm a developer of Certbot. Certbot depends on When can we expect a fix for this to be available to the Debian developers so they can continue to include |
The assertion can be made more lax but I will have to defer to @bear regarding publishing a release with that change. Is that something you could push out soon, Mike? |
yes, we can push one a release out now if needed |
@idpaterson any reason we don't use Calendar.inc() to calculate that instead of the hardcoded |
I personally don't like the test as is, it tests something different depending on the current time. The tests should test the same thing every time it is run. If you want it to test from multiple times, that should be allowed for in the tests. Instead of requiring you to run the tests multiple times throughout the year. I would suggest the fix is to hard code the source time, to something that is known to work, for example (I picked 2017-01-01 but this is arbitrary): diff --git a/tests/TestDelta.py b/tests/TestDelta.py
index c628d5e..054eabe 100644
--- a/tests/TestDelta.py
+++ b/tests/TestDelta.py
@@ -3,7 +3,6 @@
Test time delta
"""
-import time
import datetime
import unittest
import parsedatetime as pdt
@@ -13,9 +12,9 @@ class test(unittest.TestCase):
def setUp(self):
self.cal = pdt.Calendar(version=pdt.VERSION_CONTEXT_STYLE)
- self.source = (self.yr, self.mth, self.dy,
- self.hr, self.mn, self.sec,
- self.wd, self.yd, self.isdst) = time.localtime()
+ self.source = (2017, 1, 1,
+ 7, 1, 2,
+ 6, 1, 1)
def assertDelta(self, ts, years=None, months=None, **deltakw):
ts = ts[0] |
I think that test may be one of the more older of them, so is very likely broken in the sense that it's not following our current style. @idpaterson I'm all for making the change @brianmay suggests |
@bear I agree that using @brianmay the new tests for v3.0 do exactly that, every test is automatically run against a consistent set of source times. Modifying or adding to those dates is trivial, though with too many values the tests could take too long to run. I selected three dates so far: DEFAULT_SOURCE_TIMES = (
datetime(2016, 2, 29, 3, 4, 5),
datetime(2015, 2, 28, 23, 22, 21),
datetime(1945, 12, 31, 3, 4, 5),
) |
fixed in release v2.3 which i'm pushing out now - we can add more tests and switch to |
Thanks so much for fixing this unbelievably quickly. |
I know how OS packagers can be (used to be one way back in the day) and it needed fixing... long way of saying your welcome! :) |
This issue is still open but the comments suggest that the test was fixed. What's the current status? |
Bumps [parsedatetime](https://github.com/bear/parsedatetime) from 2.4 to 2.6. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/bear/parsedatetime/releases">parsedatetime's releases</a>.</em></p> <blockquote> <h2>2.6</h2> <p>Push out v2.6 to gather up local fixes and updates</p> <p>PR <a href="https://redirect.github.com/bear/parsedatetime/issues/244">#244</a> Polished README.rst PR <a href="https://redirect.github.com/bear/parsedatetime/issues/242">#242</a> fix pyicu import to suppress warnings PR <a href="https://redirect.github.com/bear/parsedatetime/issues/239">#239</a> Fixed missing comma in seconds strings</p> <p>Updated Pipfile and Makefile to: - update and move packages to the "dev" section - use Python 3.7 for pipenv - install tox-pipenv plugin to try and fix Tox (currently doesn't) - simplify tox.ini to try and fix Tox (didn't) - move ci makefile target to the circle config</p> <h2>2.5</h2> <p>v2.5 release</p> <p>PR <a href="https://redirect.github.com/bear/parsedatetime/issues/222">#222</a> Fix to sanitize abbreviated months from icu PR <a href="https://redirect.github.com/bear/parsedatetime/issues/223">#223</a> typo in RU locale in abbreviation for January PR <a href="https://redirect.github.com/bear/parsedatetime/issues/224">#224</a> Fix lint errors for flake8 v3.5.0 PR <a href="https://redirect.github.com/bear/parsedatetime/issues/225">#225</a> Add a constant for start hour PR <a href="https://redirect.github.com/bear/parsedatetime/issues/233">#233</a> Add 'secs' and 'mins' into base units PR <a href="https://redirect.github.com/bear/parsedatetime/issues/226">#226</a> Remove unused dependency on future</p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/bear/parsedatetime/blob/master/CHANGES.txt">parsedatetime's changelog</a>.</em></p> <blockquote> <p>9 Oct 2021 - bear PR <a href="https://redirect.github.com/bear/parsedatetime/issues/261">#261</a> Bump urllib3 from 1.25.9 to 1.26.5 PR <a href="https://redirect.github.com/bear/parsedatetime/issues/255">#255</a> support 'next 10 days' query PR <a href="https://redirect.github.com/bear/parsedatetime/issues/252">#252</a> Include pytest.ini in source distributions, fixes tests PR <a href="https://redirect.github.com/bear/parsedatetime/issues/250">#250</a> Update nl_NL.py PR <a href="https://redirect.github.com/bear/parsedatetime/issues/248">#248</a> pyicu 'module' object has no attribute 'Locale'</p> <pre><code>Update Pipfile to reference Python 3.9 Updated Copyright statement </code></pre> <p>31 May 2020 - bear v2.6 release bump version to v2.7</p> <p>PR <a href="https://redirect.github.com/bear/parsedatetime/issues/244">#244</a> Polished README.rst PR <a href="https://redirect.github.com/bear/parsedatetime/issues/242">#242</a> fix pyicu import to suppress warnings PR <a href="https://redirect.github.com/bear/parsedatetime/issues/239">#239</a> Fixed missing comma in seconds strings</p> <p>Updated Pipfile and Makefile to: - update and move packages to the "dev" section - use Python 3.7 for pipenv - install tox-pipenv plugin to try and fix Tox (currently doesn't) - simplify tox.ini to try and fix Tox (didn't) - move ci makefile target to the circle config</p> <p>Currently Tox is broken (see <a href="https://redirect.github.com/tox-dev/tox-pipenv/issues/61">tox-dev/tox-pipenv#61</a>)</p> <p>18 Nov 2019 - bear v2.5 release</p> <p>PR <a href="https://redirect.github.com/bear/parsedatetime/issues/222">#222</a> Fix to sanitize abbreviated months from icu PR <a href="https://redirect.github.com/bear/parsedatetime/issues/223">#223</a> typo in RU locale in abbreviation for January PR <a href="https://redirect.github.com/bear/parsedatetime/issues/224">#224</a> Fix lint errors for flake8 v3.5.0 PR <a href="https://redirect.github.com/bear/parsedatetime/issues/225">#225</a> Add a constant for start hour PR <a href="https://redirect.github.com/bear/parsedatetime/issues/233">#233</a> Add 'secs' and 'mins' into base units PR <a href="https://redirect.github.com/bear/parsedatetime/issues/226">#226</a> Remove unused dependency on future</p> <p>14 May 2017 - bear v2.4 release v2.5 bump</p> <pre><code>Issue [#219](bear/parsedatetime#219) - remove 'setup_requires' from setup.py </code></pre> <p>10 Mar 2017 - bear v2.3 release v2.4 bump</p> <pre><code>Issue [#215](bear/parsedatetime#215) - tests fail in March </code></pre> <p>02 Mar 2016 - bear</p> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/bear/parsedatetime/commit/c55337589ee582813182b74f2d3ae80e2fcd9738"><code>c553375</code></a> force update</li> <li><a href="https://github.com/bear/parsedatetime/commit/55a2b1d16df3eb9a4977be5da0ccdfc7162235d5"><code>55a2b1d</code></a> Updated Pipfile and Makefile to:</li> <li><a href="https://github.com/bear/parsedatetime/commit/50dc61787bfa703cb50d8dd0a46d7b19032e02b0"><code>50dc617</code></a> Merge pull request <a href="https://redirect.github.com/bear/parsedatetime/issues/242">#242</a> from quantrocket-llc/master</li> <li><a href="https://github.com/bear/parsedatetime/commit/acb579820dc34aa1b9aaa15a3e0afd058fad7702"><code>acb5798</code></a> Merge pull request <a href="https://redirect.github.com/bear/parsedatetime/issues/244">#244</a> from boxed/patch-2</li> <li><a href="https://github.com/bear/parsedatetime/commit/f0110909d06d48d31cdd408ea0a6764fc8b06e03"><code>f011090</code></a> Update README.rst</li> <li><a href="https://github.com/bear/parsedatetime/commit/18837504778c0dd41ae412bdf86eb81b1be7cdd7"><code>1883750</code></a> fix pyicu import to suppress warnings</li> <li><a href="https://github.com/bear/parsedatetime/commit/655783d5f96a1defd331da84478fb8f3efb0f3b9"><code>655783d</code></a> Merge pull request <a href="https://redirect.github.com/bear/parsedatetime/issues/239">#239</a> from psav/psav/fix_missing_comma</li> <li><a href="https://github.com/bear/parsedatetime/commit/7a759c1f8ff7563f12ac2c1f2ea0b41452f61dec"><code>7a759c1</code></a> Fixed missing comma in seconds strings</li> <li><a href="https://github.com/bear/parsedatetime/commit/bea2bdb56992d2ae639843cc8a961818ac394794"><code>bea2bdb</code></a> Convert to using pipenv and simplify to python 3.7 and 2.7 for testing</li> <li><a href="https://github.com/bear/parsedatetime/commit/04c095790f0a2f9b8d32f35cfbb8498e7f6dc9be"><code>04c0957</code></a> v2.6 bump</li> <li>Additional commits viewable in <a href="https://github.com/bear/parsedatetime/compare/v2.4...v2.6">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=parsedatetime&package-manager=pip&previous-version=2.4&new-version=2.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jared <97905507+jlarue26@users.noreply.github.com>
I suspect this is because February only has 28 days, not the 30 days assumed by the test.
The text was updated successfully, but these errors were encountered: