Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tests use nose.tools ok_

  • Loading branch information...
commit 1d39d9c41da75c60fb2d50bd9a8e173b182cc21c 1 parent 04322a7
@deepthawtz deepthawtz authored
Showing with 15 additions and 10 deletions.
  1. +15 −10 tests/test_api.py
View
25 tests/test_api.py
@@ -1,31 +1,35 @@
import re
-
from faker import Faker
-f = Faker()
+from nose.tools import *
+
+
+def setup():
+ global f
+ f = Faker()
def test_instance():
- assert isinstance(f, Faker)
+ ok_(isinstance(f, Faker), msg="object should be instance of Faker")
def test_fake_name():
pattern = re.compile(r"(\w+\.? ?){2,3}")
name = f.name()
- assert pattern.match(name)
+ ok_(pattern.match(name))
def test_username():
pattern = re.compile(r"[a-z]+")
username = f.username()
- assert pattern.match(username)
+ ok_(pattern.match(username))
def test_fake_email():
pattern = re.compile(r".+@.+\.\w+")
email = f.email()
- assert pattern.match(email)
+ ok_(pattern.match(email))
def test_lorem():
pattern = re.compile(r"\w*")
paragraph = f.lorem()
- assert pattern.match(paragraph)
+ ok_(pattern.match(paragraph))
def test_address():
pattern = re.compile(r"""(\d+)\s+ # first numbers
@@ -34,12 +38,13 @@ def test_address():
([A-Z][A-Z])\s+ # state
(\d{5})(-\d{4})? # zip
""", re.X)
- # to test a variety of combos
+
+ # test a variety of combos
for i in range(10):
address = f.full_address()
- assert pattern.match(address)
+ ok_(pattern.match(address))
def test_phonenumber():
pattern = re.compile(r"\d{3}-\d{3}-\d{4}")
phonenumber = f.phonenumber()
- assert pattern.match(phonenumber)
+ ok_(pattern.match(phonenumber))
Please sign in to comment.
Something went wrong with that request. Please try again.