Skip to content
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

Skipfieldfix #14

Merged
merged 3 commits into from
Oct 20, 2016
Merged

Skipfieldfix #14

merged 3 commits into from
Oct 20, 2016

Conversation

donkirkby
Copy link
Collaborator

@donkirkby donkirkby commented Oct 19, 2016

Move SkipField import out of constants.

Stops MockSet from requiring Django to be configured.

Here's an example of the problem. Before you added SkipField to constants.py, I could write a simple script that used MockSet.

from django_mock_queries.query import MockSet

print('Hello.')

Now if I do that, I get this error:

Traceback (most recent call last):
  File "/mnt/data/don/workspace/scratch/scratch.py", line 1, in <module>
    from django_mock_queries.query import MockSet
  File "/mnt/data/don/git/django-mock-queries/django_mock_queries/query.py", line 4, in <module>
    from .constants import *
  File "/mnt/data/don/git/django-mock-queries/django_mock_queries/constants.py", line 50, in <module>
    SkipField = locate('rest_framework.fields.SkipField')
  File "/usr/lib/python2.7/pydoc.py", line 1520, in locate
    nextmodule = safeimport(join(parts[:n+1], '.'), forceload)
  File "/usr/lib/python2.7/pydoc.py", line 342, in safeimport
    raise ErrorDuringImport(path, sys.exc_info())
pydoc.ErrorDuringImport: problem in rest_framework.fields - <class 'django.core.exceptions.ImproperlyConfigured'>: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I don't know if this is the best solution, but SkipField is only used in asserts.py. This pull request includes the other one for flake8.

By the way, how are you supposed to use assert_serializer? I couldn't see an example.

@codecov-io
Copy link

codecov-io commented Oct 19, 2016

Current coverage is 98.96% (diff: 100%)

Merging #14 into master will not change coverage

@@             master        #14   diff @@
==========================================
  Files             5          5          
  Lines           290        290          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits            287        287          
  Misses            3          3          
  Partials          0          0          

Powered by Codecov. Last update a8954a3...86f8396

@stphivos
Copy link
Owner

Yes I think it's a good idea. Merging this now and in case the flake8 related requirements need to be updated we can overwrite the first commit afterwards.

There is an example of assert_serializer in the README: https://github.com/stphivos/django-mock-queries#test-django-rest-framework-model-serializer. But yes, the repo could use some real docs. :)

Thanks!

@stphivos stphivos merged commit 82fc704 into stphivos:master Oct 20, 2016
@donkirkby
Copy link
Collaborator Author

Thanks, I didn't see it in the README.

@donkirkby donkirkby deleted the skipfieldfix branch October 28, 2016 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants