Skip to content

Commit af8397f

Browse files
committed
test: make file_test stateless
Previously file_test requires there is already a specific existing user in the application. This commit removes this requirement. see also #439
1 parent af8f565 commit af8397f

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

tests/test_file.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from nose.tools import raises # type: ignore
1515

1616
import leancloud
17-
from leancloud import File
17+
from leancloud import File, LeanCloudError
1818
from leancloud import ACL
1919

2020
__author__ = 'asaka'
@@ -73,7 +73,16 @@ def test_acl(): # type: () -> None
7373
@with_setup(setup_func)
7474
def test_save(): # type: () -> None
7575
user = leancloud.User()
76-
user.login('user1_name', 'password')
76+
name = 'user1_name'
77+
passwd = 'password'
78+
try:
79+
user.login(name, passwd)
80+
except LeanCloudError as e:
81+
if e.code == 211:
82+
user.set_username(name)
83+
user.set_password(passwd)
84+
user.sign_up()
85+
user.login(name, passwd)
7786

7887
f = File('Blah.txt', open('tests/sample_text.txt', 'rb'))
7988
f.save()

0 commit comments

Comments
 (0)