Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
8b77b64f
Kaydet (Commit)
8b77b64f
authored
Kas 03, 2014
tarafından
Danilo Bargen
Kaydeden (comit)
Tim Graham
Kas 03, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactored URLValidator tests by moving URLs to text files.
üst
ebc8e79c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
30 deletions
+46
-30
invalid_urls.txt
tests/validators/invalid_urls.txt
+12
-0
tests.py
tests/validators/tests.py
+18
-30
valid_urls.txt
tests/validators/valid_urls.txt
+16
-0
No files found.
tests/validators/invalid_urls.txt
0 → 100644
Dosyayı görüntüle @
8b77b64f
foo
http://
http://example
http://example.
http://.com
http://invalid-.com
http://-invalid.com
http://invalid.com-
http://inv-.alid-.com
http://inv-.-alid.com
file://localhost/path
git://example.com/
tests/validators/tests.py
Dosyayı görüntüle @
8b77b64f
...
...
@@ -2,6 +2,8 @@
from
__future__
import
unicode_literals
from
datetime
import
datetime
,
timedelta
import
io
import
os
import
re
import
types
from
unittest
import
TestCase
...
...
@@ -16,12 +18,13 @@ from django.core.validators import (
)
from
django.test
import
SimpleTestCase
from
django.test.utils
import
str_prefix
from
django.utils._os
import
upath
NOW
=
datetime
.
now
()
EXTENDED_SCHEMES
=
[
'http'
,
'https'
,
'ftp'
,
'ftps'
,
'git'
,
'file'
]
TEST_DATA
=
(
TEST_DATA
=
[
# (validator, value, expected),
(
validate_integer
,
'42'
,
None
),
(
validate_integer
,
'-42'
,
None
),
...
...
@@ -153,37 +156,9 @@ TEST_DATA = (
(
MinLengthValidator
(
10
),
''
,
ValidationError
),
(
URLValidator
(),
'http://www.djangoproject.com/'
,
None
),
(
URLValidator
(),
'HTTP://WWW.DJANGOPROJECT.COM/'
,
None
),
(
URLValidator
(),
'http://localhost/'
,
None
),
(
URLValidator
(),
'http://example.com/'
,
None
),
(
URLValidator
(),
'http://www.example.com/'
,
None
),
(
URLValidator
(),
'http://www.example.com:8000/test'
,
None
),
(
URLValidator
(),
'http://valid-with-hyphens.com/'
,
None
),
(
URLValidator
(),
'http://subdomain.example.com/'
,
None
),
(
URLValidator
(),
'http://200.8.9.10/'
,
None
),
(
URLValidator
(),
'http://200.8.9.10:8000/test'
,
None
),
(
URLValidator
(),
'http://valid-----hyphens.com/'
,
None
),
(
URLValidator
(),
'http://example.com?something=value'
,
None
),
(
URLValidator
(),
'http://example.com/index.php?something=value&another=value2'
,
None
),
(
URLValidator
(),
'https://example.com/'
,
None
),
(
URLValidator
(),
'ftp://example.com/'
,
None
),
(
URLValidator
(),
'ftps://example.com/'
,
None
),
(
URLValidator
(
EXTENDED_SCHEMES
),
'file://localhost/path'
,
None
),
(
URLValidator
(
EXTENDED_SCHEMES
),
'git://example.com/'
,
None
),
(
URLValidator
(),
'foo'
,
ValidationError
),
(
URLValidator
(),
'http://'
,
ValidationError
),
(
URLValidator
(),
'http://example'
,
ValidationError
),
(
URLValidator
(),
'http://example.'
,
ValidationError
),
(
URLValidator
(),
'http://.com'
,
ValidationError
),
(
URLValidator
(),
'http://invalid-.com'
,
ValidationError
),
(
URLValidator
(),
'http://-invalid.com'
,
ValidationError
),
(
URLValidator
(),
'http://invalid.com-'
,
ValidationError
),
(
URLValidator
(),
'http://inv-.alid-.com'
,
ValidationError
),
(
URLValidator
(),
'http://inv-.-alid.com'
,
ValidationError
),
(
URLValidator
(),
'file://localhost/path'
,
ValidationError
),
(
URLValidator
(),
'git://example.com/'
,
ValidationError
),
(
URLValidator
(
EXTENDED_SCHEMES
),
'git://-invalid.com'
,
ValidationError
),
(
BaseValidator
(
True
),
True
,
None
),
...
...
@@ -208,7 +183,20 @@ TEST_DATA = (
(
RegexValidator
(
'x'
,
flags
=
re
.
IGNORECASE
),
'y'
,
ValidationError
),
(
RegexValidator
(
'a'
),
'A'
,
ValidationError
),
(
RegexValidator
(
'a'
,
flags
=
re
.
IGNORECASE
),
'A'
,
None
),
)
]
def
create_path
(
filename
):
return
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
upath
(
__file__
)),
filename
))
# Add valid and invalid URL tests.
# This only tests the validator without extended schemes.
with
io
.
open
(
create_path
(
'valid_urls.txt'
),
encoding
=
'utf8'
)
as
f
:
for
url
in
f
:
TEST_DATA
.
append
((
URLValidator
(),
url
.
strip
(),
None
))
with
io
.
open
(
create_path
(
'invalid_urls.txt'
),
encoding
=
'utf8'
)
as
f
:
for
url
in
f
:
TEST_DATA
.
append
((
URLValidator
(),
url
.
strip
(),
ValidationError
))
def
create_simple_test_method
(
validator
,
expected
,
value
,
num
):
...
...
tests/validators/valid_urls.txt
0 → 100644
Dosyayı görüntüle @
8b77b64f
http://www.djangoproject.com/
HTTP://WWW.DJANGOPROJECT.COM/
http://localhost/
http://example.com/
http://www.example.com/
http://www.example.com:8000/test
http://valid-with-hyphens.com/
http://subdomain.example.com/
http://200.8.9.10/
http://200.8.9.10:8000/test
http://su--b.valid-----hyphens.com/
http://example.com?something=value
http://example.com/index.php?something=value&another=value2
https://example.com/
ftp://example.com/
ftps://example.com/
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