Exclude folders and line of codes from Test Coverage

Here is my coverage setup in my project. I excluded some folders and line of codes that not important in my testing.

I put these config in .coveragerc

[run]
omit =
    */urls/*
    */migrations/*
    */tests/*
    */__init__.py
    */tests.py
    */apps.py
    */rss.py
    */urls.py

[report]
exclude_lines =
    def __unicode__
    if setttings.TESTING
    def __repr__
    def __str__
Advertisements

Disable django-haystack During Testing

I use django-haystack¬†and elasticsearch for the search engine in our apps. But I don’t want my model that registered to haystack do indexing during the testing. I avoid haystack indexing by adding these following lines of code below in my settings.py.

import sys

TESTING = 'test' in sys.argv
if TESTING:
    HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.BaseSignalProcessor'
    HAYSTACK_CONNECTIONS['default'] = {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    }

Reference: https://stackoverflow.com/q/33108569/1936697

Fixing Git: refusing to merge unrelated histories

I have a new project and I add git repo later on after the project finished.
After setup remote repo to my project, I got this kind of error when pulling data from the repository.

fatal: refusing to merge unrelated histories

The problem fixed by adding this argument to git command “–allow-unrelated-histories”.

$ git pull upstream master --allow-unrelated-histories

Reference: https://stackoverflow.com/a/37938036/1936697