Skip to content

Commit a2bf0d4

Browse files
committed
+ prompt for console_qr arg
1 parent 7daffc7 commit a2bf0d4

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

tests/api/chats/test_group.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import time
2-
31
import pytest
42

53
from wxpy import *

tests/api/test_bot.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def test_create_group(self, bot):
7979
assert new_group in bot.groups()
8080
assert set(users) == set(new_group.members)
8181

82+
new_name = 'testing'
83+
new_group.rename_group(new_name)
84+
assert new_group.name == new_name
85+
8286
def test_upload_file(self, bot, file_path, friend):
8387
media_id = bot.upload_file(file_path)
8488
friend.send_file(file_path, media_id=media_id)

tests/conftest.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,20 @@ def bot():
4242
@global_use()
4343
def friend():
4444
yield _friend
45-
_friend.set_remark_name('')
45+
while True:
46+
try:
47+
_friend.set_remark_name('')
48+
except ResponseError as e:
49+
if e.err_code == 1205:
50+
time.sleep(10)
51+
continue
52+
else:
53+
break
4654

4755

4856
@global_use()
4957
def group():
50-
_group.rename_group('wxpy testing...')
51-
start = time.time()
52-
yield _group
53-
time_to_sleep = 5
54-
escaped = time.time() - start
55-
if escaped < time_to_sleep:
56-
time.sleep(time_to_sleep - escaped)
57-
_group.rename_group('wxpy test')
58+
return _group
5859

5960

6061
@global_use()

wxpy/api/bot.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ def __init__(
7979
if console_qr is True:
8080
console_qr = 2
8181

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

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

0 commit comments

Comments
 (0)