[web2py] how to run tests over pydal locally?

114 views
Skip to first unread message

Richard

unread,
Apr 29, 2015, 1:00:35 PM4/29/15
to web...@googlegroups.com
Hello,

To run web2py tests we do : python web2py.py --run_system_tests

How to run tests over pydal??

Thanks

Richard

Niphlod

unread,
Apr 29, 2015, 3:43:50 PM4/29/15
to web...@googlegroups.com
right, we should document it....

inspecting tox.ini should give you a pretty nice headstart :-P

however, if you want the "raw" command, it's

python -m unittest -v tests

same thing as "before" applies: setting a "DB" environmental variable to a backend uri makes the test run using that database.

Richard Vézina

unread,
Apr 29, 2015, 3:48:31 PM4/29/15
to web2py-users
richard@sgddms-dev:~/Documents/programmation/web2py_dev/pydal/tests$ python -m unittest -v validation.py 
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/unittest/__main__.py", line 12, in <module>
    main(module=None)
  File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/usr/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "validation.py", line 2, in <module>
    from ._compat import unittest
ValueError: Attempted relative import in non-package

:(

Richard

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Niphlod

unread,
Apr 29, 2015, 4:08:43 PM4/29/15
to web...@googlegroups.com
some time I just don't know what's going on with my writing. Am I really that obscure ?

can you spot the difference from mine


python -m unittest -v tests

and yours


python -m unittest -v validation.py

?

To be more precise (and abnoxious, maybe). Place yourself in the root dir of pydal. then copy

python -m unittest -v tests

and paste to your commandline. Then press enter.

Richard Vézina

unread,
Apr 29, 2015, 4:14:00 PM4/29/15
to web2py-users
:)

I don't test enough!!

Richard

Richard Vézina

unread,
Apr 29, 2015, 4:18:51 PM4/29/15
to web2py-users
One more I don't see my news tests executing...

Is there anything else to do then add an new file of unitttest into pydal/tests

To add news cases?

Richard

Richard Vézina

unread,
Apr 29, 2015, 4:27:01 PM4/29/15
to web2py-users
Ok, I had to do add this line to __init__.py

from .test_smart_query import *

:)

Richard

Niphlod

unread,
Apr 29, 2015, 4:28:58 PM4/29/15
to web...@googlegroups.com
oh my. Add to __init__ ^_^'

Richard Vézina

unread,
Apr 29, 2015, 4:34:47 PM4/29/15
to web2py-users
that's how validators.py is added!!

I don't find how to import smart_query

from pydal.helpers.methods import smart_query

the above returns "invalid syntax"

Richard

Richard Vézina

unread,
Apr 29, 2015, 4:38:25 PM4/29/15
to web2py-users
my bad from not form...

:(

Richard

Richard Vézina

unread,
Apr 30, 2015, 2:46:38 PM4/30/15
to web2py-users
Simone,

How can I run unittest with py.test?

Richard

Niphlod

unread,
May 3, 2015, 8:17:19 AM5/3/15
to web...@googlegroups.com
you need to rewrite the entire test-suite.

Vinicius Assef

unread,
May 4, 2015, 12:16:56 AM5/4/15
to web...@googlegroups.com
As far as the py.test docs says, you shouldn’t need to rewrite them.

py.test understands unittest tests.

Niphlod

unread,
May 4, 2015, 3:20:09 PM5/4/15
to web...@googlegroups.com, li...@viniciusban.eu.org
ok, rephrasing: in order to gain any advantage in using py.test over unittests you'd need to rewrite the entire test-suite.

if you don't rewrite them, nothing of py.test fancy features can be used.

Richard Vézina

unread,
May 5, 2015, 9:49:37 AM5/5/15
to web2py-users
:(

I find unittest not really more informative then a pointer on which line test failed... In py.test you have an few lines of the scope (let say the function call) that failed... That why I ask the question... If this is not possible for now, too bad.

Richard

Niphlod

unread,
May 5, 2015, 2:53:38 PM5/5/15
to web...@googlegroups.com
given that pretty much all tests are one-liners, I really don't see the issue at hand :P

Richard Vézina

unread,
May 5, 2015, 3:52:49 PM5/5/15
to web2py-users
Reply all
Reply to author
Forward
0 new messages