Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rename Testing Base Classes#4453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Bibo-Joshi merged 1 commit intomasterfromrename-test-classes
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletionstests/_files/test_animation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@ async def animation(bot, chat_id):
).animation


classTestAnimationBase:
classAnimationTestBase:
animation_file_id = "CgADAQADngIAAuyVeEez0xRovKi9VAI"
animation_file_unique_id = "adc3145fd2e84d95b64d68eaa22aa33e"
width = 320
Expand All@@ -66,7 +66,7 @@ class TestAnimationBase:
caption = "Test *animation*"


class TestAnimationWithoutRequest(TestAnimationBase):
class TestAnimationWithoutRequest(AnimationTestBase):
def test_slot_behaviour(self, animation):
for attr in animation.__slots__:
assert getattr(animation, attr, "err") != "err", f"got extra slot '{attr}'"
Expand DownExpand Up@@ -219,7 +219,7 @@ async def make_assertion(url, request_data: RequestData, *args, **kwargs):
)


class TestAnimationWithRequest(TestAnimationBase):
class TestAnimationWithRequest(AnimationTestBase):
async def test_send_all_args(self, bot, chat_id, animation_file, animation, thumb_file):
message = await bot.send_animation(
chat_id,
Expand Down
6 changes: 3 additions & 3 deletionstests/_files/test_audio.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,7 +49,7 @@ async def audio(bot, chat_id):
return (await bot.send_audio(chat_id, audio=f, read_timeout=50, thumbnail=thumb)).audio


classTestAudioBase:
classAudioTestBase:
caption = "Test *audio*"
performer = "Leandro Toledo"
title = "Teste"
Expand All@@ -67,7 +67,7 @@ class TestAudioBase:
audio_file_unique_id = "adc3145fd2e84d95b64d68eaa22aa33e"


class TestAudioWithoutRequest(TestAudioBase):
class TestAudioWithoutRequest(AudioTestBase):
def test_slot_behaviour(self, audio):
for attr in audio.__slots__:
assert getattr(audio, attr, "err") != "err", f"got extra slot '{attr}'"
Expand DownExpand Up@@ -222,7 +222,7 @@ async def make_assertion(url, request_data: RequestData, *args, **kwargs):
await default_bot.send_audio(chat_id, audio, reply_parameters=ReplyParameters(**kwargs))


class TestAudioWithRequest(TestAudioBase):
class TestAudioWithRequest(AudioTestBase):
async def test_send_all_args(self, bot, chat_id, audio_file, thumb_file):
message = await bot.send_audio(
chat_id,
Expand Down
4 changes: 2 additions & 2 deletionstests/_files/test_chatphoto.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,15 +52,15 @@ async def func():
)


classTestChatPhotoBase:
classChatPhotoTestBase:
chatphoto_small_file_id = "smallCgADAQADngIAAuyVeEez0xRovKi9VAI"
chatphoto_big_file_id = "bigCgADAQADngIAAuyVeEez0xRovKi9VAI"
chatphoto_small_file_unique_id = "smalladc3145fd2e84d95b64d68eaa22aa33e"
chatphoto_big_file_unique_id = "bigadc3145fd2e84d95b64d68eaa22aa33e"
chatphoto_file_url = "https://python-telegram-bot.org/static/testfiles/telegram.jpg"


class TestChatPhotoWithoutRequest(TestChatPhotoBase):
class TestChatPhotoWithoutRequest(ChatPhotoTestBase):
def test_slot_behaviour(self, chat_photo):
for attr in chat_photo.__slots__:
assert getattr(chat_photo, attr, "err") != "err", f"got extra slot '{attr}'"
Expand Down
14 changes: 7 additions & 7 deletionstests/_files/test_contact.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,21 +32,21 @@
@pytest.fixture(scope="module")
def contact():
return Contact(
TestContactBase.phone_number,
TestContactBase.first_name,
TestContactBase.last_name,
TestContactBase.user_id,
ContactTestBase.phone_number,
ContactTestBase.first_name,
ContactTestBase.last_name,
ContactTestBase.user_id,
)


classTestContactBase:
classContactTestBase:
phone_number = "+11234567890"
first_name = "Leandro"
last_name = "Toledo"
user_id = 23


class TestContactWithoutRequest(TestContactBase):
class TestContactWithoutRequest(ContactTestBase):
def test_slot_behaviour(self, contact):
for attr in contact.__slots__:
assert getattr(contact, attr, "err") != "err", f"got extra slot '{attr}'"
Expand DownExpand Up@@ -156,7 +156,7 @@ async def make_assertion(url, request_data: RequestData, *args, **kwargs):
)


class TestContactWithRequest(TestContactBase):
class TestContactWithRequest(ContactTestBase):
@pytest.mark.parametrize(
("default_bot", "custom"),
[
Expand Down
6 changes: 3 additions & 3 deletionstests/_files/test_document.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,7 +49,7 @@ async def document(bot, chat_id):
return (await bot.send_document(chat_id, document=f, read_timeout=50)).document


classTestDocumentBase:
classDocumentTestBase:
caption = "DocumentTest - *Caption*"
document_file_url = "https://python-telegram-bot.org/static/testfiles/telegram.gif"
file_size = 12948
Expand All@@ -62,7 +62,7 @@ class TestDocumentBase:
document_file_unique_id = "adc3145fd2e84d95b64d68eaa22aa33e"


class TestDocumentWithoutRequest(TestDocumentBase):
class TestDocumentWithoutRequest(DocumentTestBase):
def test_slot_behaviour(self, document):
for attr in document.__slots__:
assert getattr(document, attr, "err") != "err", f"got extra slot '{attr}'"
Expand DownExpand Up@@ -218,7 +218,7 @@ async def make_assertion(*_, **kwargs):
assert await document.get_file()


class TestDocumentWithRequest(TestDocumentBase):
class TestDocumentWithRequest(DocumentTestBase):
async def test_error_send_empty_file(self, bot, chat_id):
with Path(os.devnull).open("rb") as f, pytest.raises(TelegramError):
await bot.send_document(chat_id=chat_id, document=f)
Expand Down
34 changes: 17 additions & 17 deletionstests/_files/test_file.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,10 +31,10 @@
@pytest.fixture(scope="module")
def file(bot):
file = File(
TestFileBase.file_id,
TestFileBase.file_unique_id,
file_path=TestFileBase.file_path,
file_size=TestFileBase.file_size,
FileTestBase.file_id,
FileTestBase.file_unique_id,
file_path=FileTestBase.file_path,
file_size=FileTestBase.file_size,
)
file.set_bot(bot)
file._unfreeze()
Expand All@@ -51,10 +51,10 @@ def encrypted_file(bot):
"Pt7fKPgYWKA/7a8E64Ea1X8C+Wf7Ky1tF4ANBl63vl4=",
)
ef = File(
TestFileBase.file_id,
TestFileBase.file_unique_id,
TestFileBase.file_size,
TestFileBase.file_path,
FileTestBase.file_id,
FileTestBase.file_unique_id,
FileTestBase.file_size,
FileTestBase.file_path,
)
ef.set_bot(bot)
ef.set_credentials(fc)
Expand All@@ -69,9 +69,9 @@ def encrypted_local_file(bot):
"Pt7fKPgYWKA/7a8E64Ea1X8C+Wf7Ky1tF4ANBl63vl4=",
)
ef = File(
TestFileBase.file_id,
TestFileBase.file_unique_id,
TestFileBase.file_size,
FileTestBase.file_id,
FileTestBase.file_unique_id,
FileTestBase.file_size,
file_path=str(data_file("image_encrypted.jpg")),
)
ef.set_bot(bot)
Expand All@@ -82,16 +82,16 @@ def encrypted_local_file(bot):
@pytest.fixture(scope="module")
def local_file(bot):
file = File(
TestFileBase.file_id,
TestFileBase.file_unique_id,
FileTestBase.file_id,
FileTestBase.file_unique_id,
file_path=str(data_file("local_file.txt")),
file_size=TestFileBase.file_size,
file_size=FileTestBase.file_size,
)
file.set_bot(bot)
return file


classTestFileBase:
classFileTestBase:
file_id = "NOTVALIDDOESNOTMATTER"
file_unique_id = "adc3145fd2e84d95b64d68eaa22aa33e"
file_path = (
Expand All@@ -101,7 +101,7 @@ class TestFileBase:
file_content = "Saint-Saëns".encode() # Intentionally contains unicode chars.


class TestFileWithoutRequest(TestFileBase):
class TestFileWithoutRequest(FileTestBase):
def test_slot_behaviour(self, file):
for attr in file.__slots__:
assert getattr(file, attr, "err") != "err", f"got extra slot '{attr}'"
Expand DownExpand Up@@ -273,7 +273,7 @@ async def test(*args, **kwargs):
assert buf2[: len(buf)] == buf


class TestFileWithRequest(TestFileBase):
class TestFileWithRequest(FileTestBase):
async def test_error_get_empty_file_id(self, bot):
with pytest.raises(TelegramError):
await bot.get_file(file_id="")
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp