Skip to content

Instantly share code, notes, and snippets.

View harshvb7's full-sized avatar

Harsh harshvb7

  • Cologne, Germany
View GitHub Profile
import pytest
class TestSomething:
@pytest.fixture
def something(self):
return SomeMagic()
def test_do_something(self, something):
resp = something.do_magic()
import pytest
from example.models import Product
pytestmark = pytest.mark.django_db
class TestProductModel:
def test_save():
product = Product.objects.create(
[run]
omit =
*apps.py,
*migrations/*,
*settings*,
*tests/*,
*urls.py,
*wsgi/*,
manage.py
@harshvb7
harshvb7 / ini
Created February 18, 2017 18:29
[pytest]
DJANGO_SETTINGS_MODULE=project.test_settings
addopts = --nomigrations --cov=. --cov-report=html
from .settings import * # NOQA
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
}
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
@harshvb7
harshvb7 / req
Created February 18, 2017 18:19
pytest
pytest-django
pytest-cov
def test_hello_world():
assert "hello_world" == "hello_world"
import unittest
class TestExample(unittest.TestCase):
def test_hello_world(self):
self.assertEqual("hello world", "hello world")
@harshvb7
harshvb7 / leaflet.google.js
Created December 8, 2016 08:21
Google Layer with custom style for leaflet
/*
* L.TileLayer is used for standard xyz-numbered tile layers.
*/
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<script>
var company_field = jQuery('#acf-field-company_name');
var is_admin = jQuery('#post_author_override')[0];
if(is_admin != undefined){
company_field.select2({