Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-taggit
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
162f0857
authored
Aug 10, 2014
by
Florian Apolloner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test fixes and more 1.7 fixes.
parent
94485073
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
taggit/managers.py
+2
-1
tests/tests.py
+10
-10
No files found.
taggit/managers.py
View file @
162f0857
...
@@ -301,7 +301,8 @@ class TaggableManager(RelatedField, Field):
...
@@ -301,7 +301,8 @@ class TaggableManager(RelatedField, Field):
self
.
use_gfk
=
(
self
.
use_gfk
=
(
self
.
through
is
None
or
issubclass
(
self
.
through
,
GenericTaggedItemBase
)
self
.
through
is
None
or
issubclass
(
self
.
through
,
GenericTaggedItemBase
)
)
)
self
.
rel
.
to
=
self
.
through
.
_meta
.
get_field
(
"tag"
)
.
rel
.
to
if
not
self
.
rel
.
to
:
self
.
rel
.
to
=
self
.
through
.
_meta
.
get_field
(
"tag"
)
.
rel
.
to
self
.
related
=
RelatedObject
(
self
.
through
,
cls
,
self
)
self
.
related
=
RelatedObject
(
self
.
through
,
cls
,
self
)
if
self
.
use_gfk
:
if
self
.
use_gfk
:
tagged_items
=
GenericRelation
(
self
.
through
)
tagged_items
=
GenericRelation
(
self
.
through
)
...
...
tests/tests.py
View file @
162f0857
...
@@ -22,8 +22,8 @@ from taggit.models import Tag, TaggedItem
...
@@ -22,8 +22,8 @@ from taggit.models import Tag, TaggedItem
from
.forms
import
(
FoodForm
,
DirectFoodForm
,
CustomPKFoodForm
,
from
.forms
import
(
FoodForm
,
DirectFoodForm
,
CustomPKFoodForm
,
OfficialFoodForm
)
OfficialFoodForm
)
from
.models
import
(
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
from
.models
import
(
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
DirectHousePet
,
Tagged
Pet
,
CustomPKFood
,
CustomPKPet
,
CustomPKHousePet
,
DirectHousePet
,
Tagged
Food
,
CustomPKFood
,
CustomPKPet
,
CustomPKHousePet
,
TaggedCustomPK
Pet
,
OfficialFood
,
OfficialPet
,
OfficialHousePet
,
TaggedCustomPK
Food
,
OfficialFood
,
OfficialPet
,
OfficialHousePet
,
OfficialThroughModel
,
OfficialTag
,
Photo
,
Movie
,
Article
,
CustomManager
)
OfficialThroughModel
,
OfficialTag
,
Photo
,
Movie
,
Article
,
CustomManager
)
from
taggit.utils
import
parse_tags
,
edit_string_for_tags
from
taggit.utils
import
parse_tags
,
edit_string_for_tags
...
@@ -298,13 +298,12 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
...
@@ -298,13 +298,12 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
)
)
def
test_taggeditem_unicode
(
self
):
def
test_taggeditem_unicode
(
self
):
ross
=
self
.
pet_model
.
objects
.
create
(
name
=
"ross"
)
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
# I keep Ross Perot for a pet, what's it to you?
apple
.
tags
.
add
(
"juicy"
)
ross
.
tags
.
add
(
"president"
)
self
.
assertEqual
(
self
.
assertEqual
(
force_text
(
self
.
taggeditem_model
.
objects
.
all
()[
0
]),
force_text
(
self
.
taggeditem_model
.
objects
.
all
()[
0
]),
"
ross tagged with president
"
"
apple tagged with juicy
"
)
)
def
test_abstract_subclasses
(
self
):
def
test_abstract_subclasses
(
self
):
...
@@ -364,13 +363,13 @@ class TaggableManagerDirectTestCase(TaggableManagerTestCase):
...
@@ -364,13 +363,13 @@ class TaggableManagerDirectTestCase(TaggableManagerTestCase):
food_model
=
DirectFood
food_model
=
DirectFood
pet_model
=
DirectPet
pet_model
=
DirectPet
housepet_model
=
DirectHousePet
housepet_model
=
DirectHousePet
taggeditem_model
=
Tagged
Pet
taggeditem_model
=
Tagged
Food
class
TaggableManagerCustomPKTestCase
(
TaggableManagerTestCase
):
class
TaggableManagerCustomPKTestCase
(
TaggableManagerTestCase
):
food_model
=
CustomPKFood
food_model
=
CustomPKFood
pet_model
=
CustomPKPet
pet_model
=
CustomPKPet
housepet_model
=
CustomPKHousePet
housepet_model
=
CustomPKHousePet
taggeditem_model
=
TaggedCustomPK
Pet
taggeditem_model
=
TaggedCustomPK
Food
def
test_require_pk
(
self
):
def
test_require_pk
(
self
):
# TODO with a charfield pk, pk is never None, so taggit has no way to
# TODO with a charfield pk, pk is never None, so taggit has no way to
...
@@ -557,10 +556,11 @@ class TagStringParseTestCase(UnitTestCase):
...
@@ -557,10 +556,11 @@ class TagStringParseTestCase(UnitTestCase):
@skipIf
(
django
.
VERSION
<
(
1
,
7
),
"not relevant for Django < 1.7"
)
@skipIf
(
django
.
VERSION
<
(
1
,
7
),
"not relevant for Django < 1.7"
)
class
DeconstructTestCase
(
UnitTestCase
):
class
DeconstructTestCase
(
UnitTestCase
):
def
test_deconstruct_kwargs_kept
(
self
):
def
test_deconstruct_kwargs_kept
(
self
):
instance
=
TaggableManager
(
through
=
OfficialThroughModel
)
instance
=
TaggableManager
(
through
=
OfficialThroughModel
,
to
=
'dummy.To'
)
name
,
path
,
args
,
kwargs
=
instance
.
deconstruct
()
name
,
path
,
args
,
kwargs
=
instance
.
deconstruct
()
new_instance
=
TaggableManager
(
*
args
,
**
kwargs
)
new_instance
=
TaggableManager
(
*
args
,
**
kwargs
)
self
.
assertEqual
(
instance
.
rel
.
through
,
new_instance
.
rel
.
through
)
self
.
assertEqual
(
'tests.OfficialThroughModel'
,
new_instance
.
rel
.
through
)
self
.
assertEqual
(
'dummy.To'
,
new_instance
.
rel
.
to
)
@skipUnless
(
django
.
VERSION
<
(
1
,
7
),
"test only applies to 1.6 and below"
)
@skipUnless
(
django
.
VERSION
<
(
1
,
7
),
"test only applies to 1.6 and below"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment