Trying to lose tox. It's been a right pain.

This commit is contained in:
Dave Hall 2017-12-21 15:12:51 +00:00
parent c8fcb69099
commit ac90ba92b8
12 changed files with 63 additions and 206 deletions

3
.gitignore vendored
View File

@ -3,7 +3,6 @@
.project
.pydevproject
.settings
.tox
*.pyc
*.pyo
.bzr
@ -14,4 +13,4 @@ Thumbs.db
/dist
*.sqlite3
*.egg-info
build
build

View File

@ -1,22 +1,53 @@
language: python
sudo: false
language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
cache:
directories:
- $HOME/.cache/pip
- 3.5
- 2.7
cache: pip
env:
global:
- PYTHONWARNINGS=default,ignore::PendingDeprecationWarning,ignore::ResourceWarning
matrix:
- DJANGO='>=2.0,<2.1'
- DJANGO='>=1.11,<1.12'
- DJANGO='>=1.10,<1.11'
- DJANGO='>=1.9,<1.10'
- DJANGO='>=1.8,<1.9'
matrix:
fast_finish: true
exclude:
- python: 2.7
env: DJANGO='>=2.0,<2.1'
addons:
apt:
packages:
- libmysqlclient-dev
services:
- postgresql
- mysql
install:
- pip install tox-travis
- pip install flake8 coverage django$DJANGO psycopg2 mysqlclient -e .
before_script:
- mysql -e 'create database test_project';
- mysql -e 'create database test_project'
- psql -c 'create database test_project;' -U postgres;
script: tox
script:
- flake8
- coverage run -a tests/runtests.py
- coverage run -a tests/runtests.py -d psql
- coverage run -a tests/runtests.py -d mysql
after_success:
- coverage report
deploy:
provider: pypi
user: etianen
password:
secure: rzaq3pbJz25SVXyR/fn+gLaYxu0LqCEE+wcesg8pjA8cLLvFdLvXi0ZjmixxVl2u4HlndZrUgwTrRGVIQR1TOL0jGRYOUCJDzAaZqJkg+Qykz89iKSnentyOpNJe6fRAHsqFxBESYZjG8JEZvtRv+JIZLY+QR+KCA1xaeu4Afpw=
on:
tags: true
condition: $DJANGO='>=2.0,<2.1'
python: 3.6
repo: etianen/django-reversion
distributions: sdist bdist_wheel
notifications:
email: false

View File

@ -27,7 +27,7 @@ Please read the [Getting Started][] guide for more information.
[Getting Started]: https://github.com/etianen/django-watson/wiki
"Getting started with django-watson"
Download instructions, bug reporting and links to full documentation can be
found at the [main project website][].
@ -51,8 +51,10 @@ You can run the test suite yourself from within a virtual environment with the f
commands.
```
pip install tox
tox
pip install psycopg2 mysqlclient -e .
tests/runtests.py
tests/runtests.py -d psql
tests/runtests.py -d mysql
```
More information
@ -63,7 +65,7 @@ from the [django-watson project site][].
[django-watson project site]: http://github.com/etianen/django-watson
"django-watson on GitHub"
Dave Hall is a freelance web developer, based in Cambridge, UK. You can usually
find him on the Internet in a number of different places:

6
setup.cfg Normal file
View File

@ -0,0 +1,6 @@
[bdist_wheel]
universal = 1
[flake8]
max-line-length=120
exclude=venv,migrations

View File

@ -16,7 +16,6 @@ setup(
"watson.management",
"watson.management.commands",
"watson.migrations",
"watson.south_migrations",
"watson.templatetags",
],
package_data={

View File

@ -91,6 +91,12 @@ def main():
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
),
MIDDLEWARE=(
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
),
USE_TZ=True,
STATIC_URL="/static/",
TEST_RUNNER="django.test.runner.DiscoverRunner",

View File

@ -16,5 +16,5 @@ urlpatterns = [
"paginate_by": 10,
}),
url("^admin/", include(admin.site.urls)),
url("^admin/", admin.site.urls),
]

44
tox.ini
View File

@ -1,44 +0,0 @@
[tox]
envlist =
begin
py33-django18-{sqlite,postgres,mysql}
{py27,py34,py35}-django{18,19,110,111}-{sqlite,postgres,mysql}
py36-django111-{sqlite,postgres,mysql}
end
flake8
[testenv]
usedevelop = True
deps =
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<1.12
coverage>=4.1
postgres: psycopg2
mysql: mysqlclient
commands =
begin: coverage erase
sqlite: coverage run -a tests/runtests.py
postgres: coverage run -a tests/runtests.py -d psql
mysql: coverage run -a tests/runtests.py -d mysql
end: coverage report
[travis]
python =
2.7: begin, py27, end
3.3: begin, py33, end
3.4: begin, py34, end
3.5: begin, py35, end, flake8
3.6: begin, py36, end
[flake8]
max-line-length=120
exclude=build,venv,migrations,south_migrations,.tox
[testenv:flake8]
basepython = python3.5
deps =
flake8>=2.5.4
commands =
flake8

View File

@ -334,36 +334,6 @@ class PostgresSearchBackend(SearchBackend):
)
class PostgresLegacySearchBackend(PostgresSearchBackend):
"""
A search backend that uses native PostgreSQL full text indices.
This backend doesn't support prefix matching, and works with PostgreSQL 8.3 and below.
"""
supports_prefix_matching = False
def escape_postgres_query(self, text):
"""Escapes the given text to become a valid ts_query."""
return " & ".join(
"$${0}$$".format(word)
for word
in escape_query(text, RE_POSTGRES_ESCAPE_CHARS).split()
)
class PostgresPrefixLegacySearchBackend(RegexSearchMixin, PostgresLegacySearchBackend):
"""
A legacy search backend that uses a regexp to perform matches, but still allows
relevance rankings.
Use if your postgres vesion is less than 8.3, and you absolutely can't live without
prefix matching. Beware, this backend can get slow with large datasets!
"""
def escape_mysql_boolean_query(search_text):
return " ".join(
'+{word}*'.format(
@ -495,12 +465,6 @@ class MySQLSearchBackend(SearchBackend):
)
def get_postgresql_version(connection):
"""Returns the version number of the PostgreSQL connection."""
from django.db.backends.postgresql_psycopg2.version import get_version
return get_version(connection)
class AdaptiveSearchBackend(SearchBackend):
"""
@ -512,11 +476,7 @@ class AdaptiveSearchBackend(SearchBackend):
"""Guess the correct search backend and initialize it."""
connection = connections[router.db_for_read(SearchEntry)]
if connection.vendor == "postgresql":
version = get_postgresql_version(connection)
if version > 80400:
return PostgresSearchBackend()
if version > 80300:
return PostgresLegacySearchBackend()
return PostgresSearchBackend()
if connection.vendor == "mysql":
return MySQLSearchBackend()
return RegexSearchBackend()

View File

@ -1,56 +0,0 @@
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'SearchEntry'
db.create_table('watson_searchentry', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('engine_slug', self.gf('django.db.models.fields.CharField')(max_length=200, db_index=True)),
('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])),
('object_id', self.gf('django.db.models.fields.TextField')()),
('object_id_int', self.gf('django.db.models.fields.IntegerField')(db_index=True, null=True, blank=True)),
('title', self.gf('django.db.models.fields.CharField')(max_length=1000)),
('description', self.gf('django.db.models.fields.TextField')(blank=True)),
('content', self.gf('django.db.models.fields.TextField')(blank=True)),
('url', self.gf('django.db.models.fields.CharField')(max_length=1000, blank=True)),
('meta_encoded', self.gf('django.db.models.fields.TextField')()),
))
db.send_create_signal('watson', ['SearchEntry'])
def backwards(self, orm):
# Deleting model 'SearchEntry'
db.delete_table('watson_searchentry')
models = {
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'watson.searchentry': {
'Meta': {'object_name': 'SearchEntry'},
'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'engine_slug': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'meta_encoded': ('django.db.models.fields.TextField', [], {}),
'object_id': ('django.db.models.fields.TextField', [], {}),
'object_id_int': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
'url': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'blank': 'True'})
}
}
complete_apps = ['watson']

View File

@ -1,46 +0,0 @@
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from django.core.management import call_command
class Migration(DataMigration):
def forwards(self, orm):
"Write your forwards methods here."
# Needs to be run in a separate migration to avoid borking MySQL.
call_command("installwatson", verbosity=0)
def backwards(self, orm):
"Write your backwards methods here."
call_command("uninstallwatson", verbosity=0)
models = {
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'watson.searchentry': {
'Meta': {'object_name': 'SearchEntry'},
'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'engine_slug': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'meta_encoded': ('django.db.models.fields.TextField', [], {}),
'object_id': ('django.db.models.fields.TextField', [], {}),
'object_id_int': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
'url': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'blank': 'True'})
}
}
complete_apps = ['watson']