-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Unittest sample : Proposal for issue #4 #57
Conversation
fix setUp and tearDown in gamma.py
'list', 'log', 'mathnf', 'contfrac', 'minim', 'minmax','modfun','modular', 'nfrootsof1', 'nfsplitting', 'norm'
prec, prime, primes, qfb, qfbclassno, qfsolve, quadray
'rootsreal', 'ser', 'subst','sumdedekind', 'sumformal', 'zeta'
are installed.
are installed.
bestappr ellanal idealramgroups quadray polred
polylog gamma nfsplitting rootsreal ser subst
Test working with 2.9.3 2.8.1.beta and snapshot versions
What is the file |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the usage of unittest
very much. Though I think that you should try harder to not compare strings but actual objects. They can not do that in PARI/GP but here we do.
galpol_installed = True | ||
seadata_installed = True | ||
|
||
# test extensions presence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose to encapsulate these in functions has_seadata
, has_galpol
, has_elldata
, etc that would actually be part of the cypari2 library. Perhaps as methods of Pari
.
tests/unittests/alltest.py
Outdated
|
||
|
||
for t in testmodules: | ||
if not ((t in require_galpol and not galpol_installed) or (t in require_seadata and not seadata_installed)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change the condition to
(galpol_installed or t not in require_galpol) and (seadata_installed or t not in require_seadata)
tests/unittests/alltest.py
Outdated
|
||
for t in testmodules: | ||
if not ((t in require_galpol and not galpol_installed) or (t in require_seadata and not seadata_installed)): | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be uniform among all the files? This try/except
is a bit ugly.
@@ -0,0 +1,87 @@ | |||
import unittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should briefly document the mechanic of the tests here.
|
||
class TestBern(unittest.TestCase): | ||
def test_bern(self): | ||
pari.bernfrac(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what this is supposed to test? and why keeping ;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It test that it doesn't crash. I keep them mainly to stick with the original GP test file.
I keep ;
during developement as an help to associate results with the corresponding test.
Keeping them after can has no sense. I will remove them.
class TestBern(unittest.TestCase): | ||
def test_bern(self): | ||
pari.bernfrac(0); | ||
pari.bernfrac(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
I think that we should not add all those file to cypari2, especially because we want to support multiple versions of PARI and the version that we add is just one version. Instead we should just use |
I don't think that |
The comments |
Sorry for sounding a bit negative, but I don't quite understand why you are using unittests here. I thought that the main point of #4 was to have Python doctests. That is not what you doing here. Now it seems that you just copy PARI tests to cypari2 which is a bit pointless because it's not the job of cypari2 to test PARI. It should be the job of cypari2 to test the wrapping mechanism, not to test the PARI library itself. |
An understandable question. If the main goal is to have Python doctest this PR have no sense. But the choice of unittests is more an answer to the question "What is the good way to port GP tests into cypari2".
Can you expand on that ? |
The GP tests are a natural source of code examples (that is moreover tested). This PR is not testing PARI/GP in any way but rather if GP code can easily be ported in cypari2. It checks for coherences and helps identifying what is the missing in cypari2 vs GP. |
Add file's description. Remove the option to use test suite.
The GP doctests (i.e. the tests appearing in the PARI user documentation) are meant as documentation/examples, analogous to Python doctests. The PARI unittests (i.e. the tests in the I think it makes most sense to port the GP doctests to cypari2. Porting the PARI unittests seems useless. |
I really don't see how it can be useless. Unless you have a way to ensure that cypari2 is perfectly iso-functional with pari. Saying it's useless it's the same as saying "the wrapping is perfect and will never fail". Now what do we do with these unittest ? |
It's not that the wrapping will never fail. It's more like "the wrapping will either work or fail badly". It would be really surprising if the wrapping would work for most functions but not all. Of course, the cases where we manually wrap some functions should be tested properly. |
This pull request port some GP doctests as Python unittest.
This a solution proposal for issue #4.
A more complete but not fully working version can be found here unittest_dev.
What is your advices on this implementation ?
Comments and critics are welcome