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

Sentry should ignore all error/exceptions when running unit tests. #30

Closed
gapadventures opened this issue Oct 20, 2010 · 12 comments
Closed

Comments

@gapadventures
Copy link

It is probably not beneficial to have sentry attempt to log errors when the test harness is running.

@gapadventures
Copy link
Author

As a hack, I just put in an invalid SENTRY_REMOTE_URL in my localsettings.py file:

SENTRY_REMOTE_URL = ['http://localhost/', ]

That is enough to stop my development box from sending the errors in.

@dcramer
Copy link
Member

dcramer commented Oct 20, 2010

I can easily do this within runtests.py, but not your own test suite. The problem is I can't determine whether you're running tests or not.

@tclancy
Copy link

tclancy commented Nov 11, 2010

Is there a way to remove Sentry from settings.INSTALLED_APPS during testing? The database creation dies while trying to run a migration. I tried the following at the top of my test suite:

remove_for_testing = ['sentry', 'sentry.client']

new_apps = []
for app in settings.INSTALLED_APPS:
    if app not in remove_for_testing:
        new_apps.append(app)

settings.INSTALLED_APPS = tuple(new_apps)

but it looks like it runs too late, as South's migration manager still runs and complains there's no app named "Sentry".

@ashchristopher
Copy link

If there was a settings.py variable set to specify whether to send errors to Sentry, you could turn off sentry logging at the top of your tests.py file. Might be a little crude in that you could technically modify the settings once in any test.py file, but until there is a django test specific settings file, not too sure what else to do.

We currently specify a separate test_settings.py file where we remove sentry (and related) from the INSTALLED_APPS. It works well enough for our Hudson instance, but is kind of a pain on your development box.

@dcramer
Copy link
Member

dcramer commented Jan 13, 2011

I will add a toggle to flat out disable sentry (though it may just be specifying the client as dummy). What we do locally is have our settings.py remove sentry/sentry.client from INSTALLED_APPS.

@tclancy
Copy link

tclancy commented Jan 13, 2011

I'm happy to just do that rather than make you work around me. Can you just explain how you do that, since my code sample above isn't succeeding? Thanks.

@dcramer
Copy link
Member

dcramer commented Jan 13, 2011

tclancy, wrote this up real quick: http://justcramer.com/2011/01/13/settings-in-django/

@tclancy
Copy link

tclancy commented Jan 13, 2011

That's awesome, thanks so much. It's usually just me, so I get away with the local_settings.py file, but that's good stuff.

@maraujop
Copy link

Shouldn't this be closed?

@dcramer
Copy link
Member

dcramer commented Feb 14, 2011

Yes, it should :)

@tclancy
Copy link

tclancy commented Mar 4, 2011

Totally lazy person's solution: rename/ delete/ move Sentry's /migrations folder.

@tclancy
Copy link

tclancy commented Mar 4, 2011

And 12 seconds later, an actual, mature fix for the problem I was having: SOUTH_TESTS_MIGRATE = False in your settings file.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants