i've been working on an OS app for a while now and am having trouble getting tests to pass b/c i have to use @override_settings to set which model to serve as an api
Koterpillar
glassresistor: please continue
glassresistor
i have a function called get_search_model and use it everywhere which returns the model set in settings
this is of course the doucmented way to do it but because what im doing is effectively lettings a project swap out the model used by forms and restframework
im getting bad results
Koterpillar
how do you define "bad results" and what do they have to do with this setting?
ghostlight joined the channel
glassresistor
Koterpillar: im getting there sorry
Koterpillar: now when i run my tests with the settings defined the same as the override the tests pass just fine but when i use settings different from the override i get lots of errors
krfa has quit
OtherAllan has quit
Koterpillar: the settings defines what model a restframework api will use
Ankhers joined the channel
Koterpillar: i've done a bit of debugging but add these two lines of code to the get_search_model function and running my tests
so what im setting is that even though once the tests themselves are running the overrides are taking effect but during the initial setup phase its using the settings defined in the settings file
Koterpillar
can I see matcher/forms.py?
glassresistor
so the forms, admin, and serializers all get defined with the projects settings instead of the tests settings
Koterpillar
also, raise an exception instead, you'll get a full stack trace
barajasfab has quit
koniiiik joined the channel
glassresistor
Koterpillar: sure although in this case the form and admin are not part of the main app but rather the project and its the serializers with the wrong settings being the issue
actually, this means you can't import any of those things before apps are loaded
glassresistor
Koterpillar: not sure the serializers have to load on module load because thats how restframework does it, same with forms/admin(luckily those dont matter for this case)
Koterpillar: so i don't think i can force the serializers to load when the views are called because the serializers are collected and cahed similar to how models are to avoid circular dependencies
GuyYotine joined the channel
Koterpillar
can you still raise an exception and paste the traceback from when you run tests?
glassresistor
Koterpillar: i've got the sinking feeling the only solution is to have django allow for an app to change settings before the models load but i don't think thats doable for many reasons
Koterpillar: the pastebin includes all of the tracebacks from the tests
Koterpillar
no, raise an exception in get_search_model
SecondForm_Glenn has quit
glassresistor
Koterpillar: sure i mean i was basically doing that just by printing the stack()[1] in the test output but and ill want to skip the errors because the 3rd call is the interesting one to serializers
Koterpillar
no
you get the bottom of each trace
I want the entirety of one trace
glassresistor
ok one sec
Genitrust has quit
Sonderblade joined the channel
Koterpillar
(it could be just inspect.stack(), but that's hard to read)