Skip to content

Commit

Permalink
+ prompt for console_qr arg
Browse files Browse the repository at this point in the history
  • Loading branch information
youfou committed Jun 8, 2017
1 parent 7daffc7 commit a2bf0d4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 0 additions & 2 deletions tests/api/chats/test_group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import time

import pytest

from wxpy import *
Expand Down
4 changes: 4 additions & 0 deletions tests/api/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def test_create_group(self, bot):
assert new_group in bot.groups()
assert set(users) == set(new_group.members)

new_name = 'testing'
new_group.rename_group(new_name)
assert new_group.name == new_name

def test_upload_file(self, bot, file_path, friend):
media_id = bot.upload_file(file_path)
friend.send_file(file_path, media_id=media_id)
19 changes: 10 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@ def bot():
@global_use()
def friend():
yield _friend
_friend.set_remark_name('')
while True:
try:
_friend.set_remark_name('')
except ResponseError as e:
if e.err_code == 1205:
time.sleep(10)
continue
else:
break


@global_use()
def group():
_group.rename_group('wxpy testing...')
start = time.time()
yield _group
time_to_sleep = 5
escaped = time.time() - start
if escaped < time_to_sleep:
time.sleep(time_to_sleep - escaped)
_group.rename_group('wxpy test')
return _group


@global_use()
Expand Down
14 changes: 9 additions & 5 deletions wxpy/api/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ def __init__(
if console_qr is True:
console_qr = 2

self.core.auto_login(
hotReload=bool(cache_path), statusStorageDir=cache_path,
enableCmdQR=console_qr, picDir=qr_path, qrCallback=qr_callback,
loginCallback=login_callback, exitCallback=logout_callback
)
try:
self.core.auto_login(
hotReload=bool(cache_path), statusStorageDir=cache_path,
enableCmdQR=console_qr, picDir=qr_path, qrCallback=qr_callback,
loginCallback=login_callback, exitCallback=logout_callback
)
except FileNotFoundError as e:
if e.filename == 'xdg-open':
raise Exception('use `console_qr` arg while under pure console environment')

# 用于 "synccheck" 请求的 "_" 参数,每次请求时 + 1
self._sync_check_iterations = int(time.time() * 1000)
Expand Down

0 comments on commit a2bf0d4

Please sign in to comment.