Added my custom code directory to the view folder, and then “env/bin/pytest -q” throws error , on Command line my code works fine

15 views
Skip to first unread message

Joseph John

unread,
Nov 11, 2019, 10:53:14 PM11/11/19
to pylons-discuss
Hi All,
Good morning
I am trying to explore Pyramid, very much new to  Pyramid, have done basic python programming , world of web framework in new to me.
I have read the docs, started step by step.  Created project using “cookiecutter”, also tried out quick tutorials on how to create the simple pyramid application. Read about “views”. Did the configuration setting for PostgreSQL using setup.py(import psycopg2) and development.ini (sqlalchemy.url = postgresql://itsupport:a@localhost:5432/dvdrental),  after doing the changes I did “env/bin/pytest  -q”   and was able to start the webframework.  Good so far, next level of learning I had  faced issues, posting the details

I am trying to go to next level,  On command line  already I have created a sample program which reads a data from the PostgreSQL, and display. This works fine on command line. Now I added this program “directory” to the view directory,  and then when I run the  “env/bin/pytest  -q”   I am faciing this messages


>   from myconfig import config
E   ModuleNotFoundError: No module named 'myconfig'
dvd_scaffold/views/dvdrental/toplistrented.py:5: ModuleNotFoundError


Advice and guidance requested on how to solve it.  Any URL pointing to the particular issues documentation would be great
I am using the Ubuntu 18.04 as OS , and python 3.6.8


Thanks
Joseph John

Steve Piercy

unread,
Nov 12, 2019, 12:37:56 AM11/12/19
to pylons-...@googlegroups.com
pytest is a test runner. It is not an app runner. To run the
app, you would use:

env/bin/pserve development.ini

You would need to provide a complete and reproducible example.
The error indicates that the module myconfig cannot be
imported. That could be due to either not re-installing your
app after making changes or an incorrect path to the module.

--steve


On 11/11/19 at 7:53 PM, jjk....@gmail.com (Joseph John) pronounced:
------------------------
Steve Piercy, Eugene, OR

Joseph John

unread,
Nov 12, 2019, 1:47:06 AM11/12/19
to pylons-discuss

Thanks Steve,
I did "from . import config" in __init__.py  and the error message gone,
Thanks for the reply


On Tuesday, November 12, 2019 at 9:37:56 AM UTC+4, Steve Piercy wrote:
pytest is a test runner.  It is not an app runner.  To run the
app, you would use:

     env/bin/pserve development.ini

You would need to provide a complete and reproducible example.  
The error indicates that the module myconfig cannot be
imported.  That could be due to either not re-installing your
app after making changes or an incorrect path to the module.

--steve


On 11/11/19 at 7:53 PM, jjk...@gmail.com (Joseph John) pronounced:
Reply all
Reply to author
Forward
0 new messages