Skip to content

Commit

Permalink
pyhton3 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
un1t committed Feb 21, 2015
1 parent d1d91f5 commit a0901e5
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build/
dist/
*.egg-info/
*.pyc
*.egg-info
.tox
40 changes: 26 additions & 14 deletions README.markdown → README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# django-cleanup

django-cleanup automatically deletes old file for FileField, ImageField and subclasses,
and it also deletes files on models instance deletion.

Expand All @@ -8,19 +6,29 @@ If you are concerned about it you need other solution for old file deletion in y

Most django projects I've seen don't use transactions and this app is designed for such projects.

## How does it work?
Features
========

- Support for Django 1.3, 1.4, 1.5, 1.6 and 1.7
- Python 3 support


How does it work?
=================

django-cleanup connects pre_save and post_delete signals to special functions(these functions
delete old files) for each model which app is listed in INSTALLED_APPS above than 'django_cleanup'.

## Installation
Installation
============

pip install django-cleanup


## Configuration
Configuration
=============

Add django_cleanup to settings.py
Add django_cleanup to settings.py ::

INSTALLED_APPS = (
...
Expand All @@ -30,14 +38,17 @@ Add django_cleanup to settings.py
**django_cleanup** should be placed after all your apps. (At least after those apps which need to remove files.)


## Signals
Signals
=======

django-cleanup sends the following signals which can be imported from `django_cleanup.signals`:

* `cleanup_pre_delete` just _before_ a file is deleted. Passes a `file` keyword argument.
* `cleanup_post_delete` just _after_ a file is deleted. Passes a `file` keyword argument.
- **cleanup_pre_delete** just before a file is deleted. Passes a `file` keyword argument.
- **cleanup_post_delete** just after a file is deleted. Passes a `file` keyword argument.

### Signals example for sorl.thumbnail
Signals example for sorl.thumbnail
----------------------------------
::

from django_cleanup.signals import cleanup_pre_delete, cleanup_post_delete
Expand All @@ -47,13 +58,14 @@ django-cleanup sends the following signals which can be imported from `django_cl
cleanup_pre_delete.connect(sorl_delete)

## How to run tests
How to run tests
================

pip install -r django_cleanup/testapp/requirements.txt
./runtests.py
tox


## License
License
=======

django-cleanup is free software under terms of the MIT License.

Expand Down
2 changes: 1 addition & 1 deletion django_cleanup/testapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@


class Product(models.Model):
image = models.ImageField(upload_to='testapp', blank=True)
image = models.FileField(upload_to='testapp', blank=True)
4 changes: 3 additions & 1 deletion django_cleanup/testapp/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
django
django>1.7,<1.8
django-nose
pinocchio
flexmock
7 changes: 7 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
'django_cleanup',
),
MIDDLEWARE_CLASSES = [],
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner',
NOSE_ARGS = [
'--with-spec',
'--spec-color',
'--verbosity=2',
'--nocapture',
],
)

if __name__ == "__main__":
Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

setup(
name = 'django-cleanup',
version = '0.1.12',
version = '0.1.13',
packages = ['django_cleanup'],
include_package_data=True,
requires = ['python (>= 2.5)', 'django (>= 1.3)'],
description = 'Deletes old files.',
long_description = open('README.markdown').read(),
long_description = open('README.rst').read(),
author = 'Ilya Shalyapin',
author_email = 'ishalyapin@gmail.com',
url = 'https://github.com/un1t/django-cleanup',
Expand All @@ -29,5 +29,9 @@
'Framework :: Django',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
],
)
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tox]
envlist = py27,py34
[testenv]
deps = -rdjango_cleanup/testapp/requirements.txt
commands=./runtests.py

0 comments on commit a0901e5

Please sign in to comment.