repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/recursive_error.py | examples/recursive_error.py | """
Demonstrates Rich tracebacks for recursion errors.
Rich can exclude frames in the middle to avoid huge tracebacks.
"""
from rich.console import Console
def foo(n):
return bar(n)
def bar(n):
return foo(n)
console = Console()
try:
foo(1)
except Exception:
console.print_exception(max_frames=... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/exception.py | examples/exception.py | """
Basic example to show how to print an traceback of an exception
"""
from typing import List, Tuple
from rich.console import Console
console = Console()
def divide_by(number: float, divisor: float) -> float:
"""Divide any number by zero."""
# Will throw a ZeroDivisionError if divisor is 0
result = nu... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/table.py | examples/table.py | """
Demonstrates how to render a table.
"""
from rich.console import Console
from rich.table import Table
table = Table(title="Star Wars Movies")
table.add_column("Released", style="cyan", no_wrap=True)
table.add_column("Title", style="magenta")
table.add_column("Box Office", justify="right", style="green")
table.a... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/justify.py | examples/justify.py | """
This example demonstrates the justify argument to print.
"""
from rich.console import Console
console = Console(width=20)
style = "bold white on blue"
console.print("Rich", style=style)
console.print("Rich", style=style, justify="left")
console.print("Rich", style=style, justify="center")
console.print("Rich", s... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/link.py | examples/link.py | from rich import print
print("If your terminal supports links, the following text should be clickable:")
print("[link=https://www.willmcgugan.com][i]Visit [red]my[/red][/i] [yellow]Blog[/]")
| python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/export.py | examples/export.py | """
Demonstrates export console output
"""
from rich.console import Console
from rich.table import Table
console = Console(record=True)
def print_table():
table = Table(title="Star Wars Movies")
table.add_column("Released", style="cyan", no_wrap=True)
table.add_column("Title", style="magenta")
tabl... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/tree.py | examples/tree.py | """
Demonstrates how to display a tree of files / directories with the Tree renderable.
"""
import os
import pathlib
import sys
from rich import print
from rich.filesize import decimal
from rich.markup import escape
from rich.text import Text
from rich.tree import Tree
def walk_directory(directory: pathlib.Path, tr... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/suppress.py | examples/suppress.py | try:
import click
except ImportError:
print("Please install click for this example")
print(" pip install click")
exit()
from rich.traceback import install
install(suppress=[click])
@click.command()
@click.option("--count", default=1, help="Number of greetings.")
def hello(count):
"""Simple pr... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/fullscreen.py | examples/fullscreen.py | """
Demonstrates a Rich "application" using the Layout and Live classes.
"""
from datetime import datetime
from rich import box
from rich.align import Align
from rich.console import Console, Group
from rich.layout import Layout
from rich.panel import Panel
from rich.progress import BarColumn, Progress, SpinnerColumn... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/group2.py | examples/group2.py | from rich import print
from rich.console import group
from rich.panel import Panel
@group()
def get_panels():
yield Panel("Hello", style="on blue")
yield Panel("World", style="on red")
print(Panel(get_panels()))
| python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/log.py | examples/log.py | """
A simulation of Rich console logging.
"""
import time
from rich.console import Console
from rich.style import Style
from rich.theme import Theme
from rich.highlighter import RegexHighlighter
class RequestHighlighter(RegexHighlighter):
base_style = "req."
highlights = [
r"^(?P<protocol>\w+) (?P<me... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/overflow.py | examples/overflow.py | from typing import List
from rich.console import Console, OverflowMethod
console = Console(width=14)
supercali = "supercalifragilisticexpialidocious"
overflow_methods: List[OverflowMethod] = ["fold", "crop", "ellipsis"]
for overflow in overflow_methods:
console.rule(overflow)
console.print(supercali, overflow... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/bars.py | examples/bars.py | """
Use Bar to renderer a sort-of circle.
"""
import math
from rich.align import Align
from rich.bar import Bar
from rich.color import Color
from rich import print
SIZE = 40
for row in range(SIZE):
y = (row / (SIZE - 1)) * 2 - 1
x = math.sqrt(1 - y * y)
color = Color.from_rgb((1 + y) * 127.5, 0, 0)
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/attrs.py | examples/attrs.py | from typing import List
try:
import attr
except ImportError:
print("This example requires attrs library")
print("pip install attrs")
raise SystemExit()
@attr.define
class Point3D:
x: float
y: float
z: float = 0
@attr.define
class Triangle:
point1: Point3D
point2: Point3D
poi... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/jobs.py | examples/jobs.py | from time import sleep
from rich.panel import Panel
from rich.progress import Progress
JOBS = [100, 150, 25, 70, 110, 90]
progress = Progress(auto_refresh=False)
master_task = progress.add_task("overall", total=sum(JOBS))
jobs_task = progress.add_task("jobs")
progress.console.print(
Panel(
"[bold blue]A... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/top_lite_simulator.py | examples/top_lite_simulator.py | """Lite simulation of the top linux command."""
import datetime
import random
import time
from dataclasses import dataclass
from rich import box
from rich.console import Console
from rich.live import Live
from rich.table import Table
from typing import Literal
@dataclass
class Process:
pid: int
command: str
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/screen.py | examples/screen.py | """
Demonstration of Console.screen()
"""
from time import sleep
from rich.align import Align
from rich.console import Console
from rich.panel import Panel
console = Console()
with console.screen(style="bold white on red") as screen:
text = Align.center("[blink]Don't Panic![/blink]", vertical="middle")
scr... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/group.py | examples/group.py | from rich import print
from rich.console import Group
from rich.panel import Panel
panel_group = Group(
Panel("Hello", style="on blue"),
Panel("World", style="on red"),
)
print(Panel(panel_group))
| python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/downloader.py | examples/downloader.py | """
A rudimentary URL downloader (like wget or curl) to demonstrate Rich progress bars.
"""
import os.path
import sys
from concurrent.futures import ThreadPoolExecutor
import signal
from functools import partial
from threading import Event
from typing import Iterable
from urllib.request import urlopen
from rich.progr... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/highlighter.py | examples/highlighter.py | """
This example demonstrates a simple text highlighter.
"""
from rich.console import Console
from rich.highlighter import RegexHighlighter
from rich.theme import Theme
class EmailHighlighter(RegexHighlighter):
"""Apply style to anything that looks like an email."""
base_style = "example."
highlights = ... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/dynamic_progress.py | examples/dynamic_progress.py | """
Demonstrates how to create a dynamic group of progress bars,
showing multi-level progress for multiple tasks (installing apps in the example),
each of which consisting of multiple steps.
"""
import time
from rich.console import Group
from rich.panel import Panel
from rich.live import Live
from rich.progress imp... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/print_calendar.py | examples/print_calendar.py | """
Builds calendar layout using Columns and Tables.
Usage:
python print_calendar.py [YEAR]
Example:
python print_calendar.py 2021
"""
import argparse
import calendar
from datetime import datetime
from rich.align import Align
from rich import box
from rich.columns import Columns
from rich.console import Console
from r... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/file_progress.py | examples/file_progress.py | from time import sleep
from urllib.request import urlopen
from rich.progress import wrap_file
# Read a URL with urlopen
response = urlopen("https://www.textualize.io")
# Get the size from the headers
size = int(response.headers["Content-Length"])
# Wrap the response so that it update progress
with wrap_file(respons... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/status.py | examples/status.py | from time import sleep
from rich.console import Console
console = Console()
console.print()
tasks = [f"task {n}" for n in range(1, 11)]
with console.status("[bold green]Working on tasks...") as status:
while tasks:
task = tasks.pop(0)
sleep(1)
console.log(f"{task} complete")
| python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/spinners.py | examples/spinners.py | from time import sleep
from rich.columns import Columns
from rich.panel import Panel
from rich.live import Live
from rich.text import Text
from rich.spinner import Spinner, SPINNERS
all_spinners = Columns(
[
Spinner(spinner_name, text=Text(repr(spinner_name), style="green"))
for spinner_name in so... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/listdir.py | examples/listdir.py | """
A very simple `ls` clone.
If your terminal supports hyperlinks you should be able to launch files by clicking the filename
(usually with cmd / ctrl).
"""
import os
import sys
from rich import print
from rich.columns import Columns
from rich.text import Text
try:
root_path = sys.argv[1]
except IndexError:
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/repr.py | examples/repr.py | import rich.repr
@rich.repr.auto
class Bird:
def __init__(self, name, eats=None, fly=True, extinct=False):
self.name = name
self.eats = list(eats) if eats else []
self.fly = fly
self.extinct = extinct
# Note that the repr is still generated without Rich
# Try commenting out the f... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/live_progress.py | examples/live_progress.py | """
Demonstrates the use of multiple Progress instances in a single Live display.
"""
from time import sleep
from rich.live import Live
from rich.panel import Panel
from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn
from rich.table import Table
job_progress = Progress(
"{task.descrip... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/table_movie.py | examples/table_movie.py | """Same as the table_movie.py but uses Live to update"""
import time
from contextlib import contextmanager
from rich import box
from rich.align import Align
from rich.console import Console
from rich.live import Live
from rich.table import Table
from rich.text import Text
TABLE_DATA = [
[
"May 25, 1977",
... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/padding.py | examples/padding.py | from rich import print
from rich.padding import Padding
test = Padding("Hello", (2, 4), style="on blue", expand=False)
print(test)
| python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/layout.py | examples/layout.py | """
Demonstrates a dynamic Layout
"""
from datetime import datetime
from time import sleep
from rich.align import Align
from rich.console import Console
from rich.layout import Layout
from rich.live import Live
from rich.text import Text
console = Console()
layout = Layout()
layout.split(
Layout(name="header... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
Textualize/rich | https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/cp_progress.py | examples/cp_progress.py | """
A very minimal `cp` clone that displays a progress bar.
"""
import os
import shutil
import sys
from rich.progress import Progress
if __name__ == "__main__":
if len(sys.argv) == 3:
with Progress() as progress:
desc = os.path.basename(sys.argv[1])
with progress.open(sys.argv[1], ... | python | MIT | 53757bc234cf18977cade41a5b64f3abaccb0b85 | 2026-01-04T14:39:17.105051Z | false |
minimaxir/big-list-of-naughty-strings | https://github.com/minimaxir/big-list-of-naughty-strings/blob/db33ec7b1d5d9616a88c76394b7d0897bd0b97eb/scripts/txt_to_json.py | scripts/txt_to_json.py | ### Quick Python Script to convert the Big List of Naughty Strings into a JSON file
###
### By Max Woolf
import json
with open('../blns.txt', 'r') as f:
# put all lines in the file into a Python list
content = f.readlines()
# above line leaves trailing newline characters; strip them out
content... | python | MIT | db33ec7b1d5d9616a88c76394b7d0897bd0b97eb | 2026-01-04T14:39:35.128087Z | false |
minimaxir/big-list-of-naughty-strings | https://github.com/minimaxir/big-list-of-naughty-strings/blob/db33ec7b1d5d9616a88c76394b7d0897bd0b97eb/naughtystrings/__init__.py | naughtystrings/__init__.py | import os
FILEPATH = os.path.join(
os.path.abspath(os.path.dirname(os.path.dirname(__file__))), 'blns.txt')
"""Path to the file"""
def naughty_strings(filepath=FILEPATH):
"""Get the list of naughty_strings.
By default this will get the strings from the blns.txt file
Code is a simple port of what i... | python | MIT | db33ec7b1d5d9616a88c76394b7d0897bd0b97eb | 2026-01-04T14:39:35.128087Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/setup.py | setup.py | """Setup script for MetaGPT."""
import subprocess
from pathlib import Path
from setuptools import Command, find_packages, setup
class InstallMermaidCLI(Command):
"""A custom command to run `npm install -g @mermaid-js/mermaid-cli` via a subprocess."""
description = "install mermaid-cli"
user_options = []... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/conftest.py | tests/conftest.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/1 12:10
@Author : alexanderwu
@File : conftest.py
"""
import asyncio
import json
import logging
import os
import re
import uuid
from typing import Callable
import aiohttp.web
import pytest
from metagpt.const import DEFAULT_WORKSPACE_ROOT, TEST_D... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/__init__.py | tests/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/4/29 15:53
@Author : alexanderwu
@File : __init__.py
"""
| python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/mock/mock_curl_cffi.py | tests/mock/mock_curl_cffi.py | import json
from typing import Callable
from curl_cffi import requests
origin_request = requests.Session.request
class MockCurlCffiResponse(requests.Response):
check_funcs: dict[tuple[str, str], Callable[[dict], str]] = {}
rsp_cache: dict[str, str] = {}
name = "curl-cffi"
def __init__(self, session... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/mock/mock_llm.py | tests/mock/mock_llm.py | import json
from typing import Optional, Union
from metagpt.config2 import config
from metagpt.configs.llm_config import LLMType
from metagpt.const import LLM_API_TIMEOUT
from metagpt.logs import logger
from metagpt.provider.azure_openai_api import AzureOpenAILLM
from metagpt.provider.constant import GENERAL_FUNCTION_... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/mock/mock_aiohttp.py | tests/mock/mock_aiohttp.py | import json
from typing import Callable
from aiohttp.client import ClientSession
origin_request = ClientSession.request
class MockAioResponse:
check_funcs: dict[tuple[str, str], Callable[[dict], str]] = {}
rsp_cache: dict[str, str] = {}
name = "aiohttp"
status = 200
def __init__(self, session, ... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/mock/mock_httplib2.py | tests/mock/mock_httplib2.py | import json
from typing import Callable
from urllib.parse import parse_qsl, urlparse
import httplib2
origin_request = httplib2.Http.request
class MockHttplib2Response(httplib2.Response):
check_funcs: dict[tuple[str, str], Callable[[dict], str]] = {}
rsp_cache: dict[str, str] = {}
name = "httplib2"
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_llm.py | tests/metagpt/test_llm.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/11 14:45
@Author : alexanderwu
@File : test_llm.py
"""
import pytest
from metagpt.llm import LLM
@pytest.fixture()
def llm():
return LLM()
@pytest.mark.asyncio
async def test_llm_aask(llm):
rsp = await llm.aask("hello world", stream=F... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_reporter.py | tests/metagpt/test_reporter.py | import ast
from contextlib import asynccontextmanager
import aiohttp.web
import pytest
from metagpt.logs import log_llm_stream
from metagpt.utils.report import (
END_MARKER_NAME,
BlockType,
BrowserReporter,
DocsReporter,
EditorReporter,
NotebookReporter,
ServerReporter,
TaskReporter,
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_incremental_dev.py | tests/metagpt/test_incremental_dev.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2024/01/03
@Author : mannaandpoem
@File : test_incremental_dev.py
"""
import os
import shutil
import subprocess
import time
import pytest
from typer.testing import CliRunner
from metagpt.const import TEST_DATA_PATH
from metagpt.logs import logger
from m... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_software_company.py | tests/metagpt/test_software_company.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/15 11:40
@Author : alexanderwu
@File : test_software_company.py
"""
import pytest
from typer.testing import CliRunner
from metagpt.logs import logger
from metagpt.software_company import app
from metagpt.team import Team
runner = CliRunner()
@p... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_environment.py | tests/metagpt/test_environment.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/12 00:47
@Author : alexanderwu
@File : test_environment.py
"""
from pathlib import Path
import pytest
from metagpt.actions import UserRequirement
from metagpt.actions.prepare_documents import PrepareDocuments
from metagpt.context import Context
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_config.py | tests/metagpt/test_config.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2024/1/9 15:57
@Author : alexanderwu
@File : test_config.py
"""
from metagpt.config2 import Config
from metagpt.configs.llm_config import LLMType
from tests.metagpt.provider.mock_llm_config import mock_llm_config
def test_config_1():
cfg = Config.d... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_team.py | tests/metagpt/test_team.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc : unittest of team
from metagpt.roles.project_manager import ProjectManager
from metagpt.team import Team
def test_team():
company = Team()
company.hire([ProjectManager()])
assert len(company.env.roles) == 1
| python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_role.py | tests/metagpt/test_role.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/11 14:44
@Author : alexanderwu
@File : test_role.py
@Modified By: mashenquan, 2023-11-1. In line with Chapter 2.2.1 and 2.2.2 of RFC 116, introduce unit tests for
the utilization of the new message distribution feature in message handli... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_prompt.py | tests/metagpt/test_prompt.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/11 14:45
@Author : alexanderwu
@File : test_llm.py
"""
import pytest
from metagpt.llm import LLM
CODE_REVIEW_SMALLEST_CONTEXT = """
## game.js
```Code
// game.js
class Game {
constructor() {
this.board = this.createEmptyBoard();
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_context.py | tests/metagpt/test_context.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2024/1/9 13:52
@Author : alexanderwu
@File : test_context.py
"""
from metagpt.configs.llm_config import LLMType
from metagpt.context import AttrDict, Context
def test_attr_dict_1():
ad = AttrDict(name="John", age=30)
assert ad.name == "John"
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_context_mixin.py | tests/metagpt/test_context_mixin.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2024/1/11 19:24
@Author : alexanderwu
@File : test_context_mixin.py
"""
from pathlib import Path
import pytest
from pydantic import BaseModel
from metagpt.actions import Action
from metagpt.config2 import Config
from metagpt.const import CONFIG_ROOT
fro... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/__init__.py | tests/metagpt/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/4/29 16:01
@Author : alexanderwu
@File : __init__.py
"""
| python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_message.py | tests/metagpt/test_message.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/16 10:57
@Author : alexanderwu
@File : test_message.py
@Modified By: mashenquan, 2023-11-1. Modify coding style.
"""
import pytest
from metagpt.schema import AIMessage, Message, SystemMessage, UserMessage
def test_message():
msg = Message(ro... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_subscription.py | tests/metagpt/test_subscription.py | import asyncio
import pytest
from metagpt.roles import Role
from metagpt.schema import Message
from metagpt.subscription import SubscriptionRunner
@pytest.mark.asyncio
async def test_subscription_run():
callback_done = 0
async def trigger():
while True:
yield Message(content="the latest... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_repo_parser.py | tests/metagpt/test_repo_parser.py | from pathlib import Path
from pprint import pformat
import pytest
from metagpt.const import METAGPT_ROOT
from metagpt.logs import logger
from metagpt.repo_parser import DotClassAttribute, DotClassMethod, DotReturn, RepoParser
def test_repo_parser():
repo_parser = RepoParser(base_directory=METAGPT_ROOT / "metagp... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_document.py | tests/metagpt/test_document.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2024/1/2 21:00
@Author : alexanderwu
@File : test_document.py
"""
from metagpt.config2 import config
from metagpt.document import Repo
from metagpt.logs import logger
def set_existing_repo(path):
repo1 = Repo.from_path(path)
repo1.set("doc/wtf_f... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/test_schema.py | tests/metagpt/test_schema.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/20 10:40
@Author : alexanderwu
@File : test_schema.py
@Modified By: mashenquan, 2023-11-1. In line with Chapter 2.2.1 and 2.2.2 of RFC 116, introduce unit tests for
the utilization of the new feature of `Message` class.
"""
import json... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/management/test_skill_manager.py | tests/metagpt/management/test_skill_manager.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/6/6 12:38
@Author : alexanderwu
@File : test_skill_manager.py
"""
from metagpt.actions import WritePRD, WriteTest
from metagpt.logs import logger
from metagpt.management.skill_manager import SkillManager
def test_skill_manager():
manager = Skil... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/management/__init__.py | tests/metagpt/management/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/6/6 12:38
@Author : alexanderwu
@File : __init__.py
"""
| python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_web_browser_engine.py | tests/metagpt/tools/test_web_browser_engine.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import pytest
from metagpt.tools import WebBrowserEngineType, web_browser_engine
from metagpt.utils.parse_html import WebPage
@pytest.mark.asyncio
@pytest.mark.parametrize(
"browser_type",
[
WebBrowserEngineType.PLAYWRIGHT,
WebBrowserEngineType.S... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_web_browser_engine_playwright.py | tests/metagpt/tools/test_web_browser_engine_playwright.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import pytest
from metagpt.tools import web_browser_engine_playwright
from metagpt.utils.parse_html import WebPage
@pytest.mark.asyncio
@pytest.mark.parametrize(
"browser_type, use_proxy, kwagrs,",
[
("chromium", {"proxy": True}, {}),
(
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_prompt_writer.py | tests/metagpt/tools/test_prompt_writer.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/2 17:46
@Author : alexanderwu
@File : test_prompt_writer.py
"""
import pytest
from metagpt.logs import logger
from metagpt.tools.prompt_writer import (
BEAGECTemplate,
EnronTemplate,
GPTPromptGenerator,
WikiHowTemplate,
)
@pytes... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_iflytek_tts.py | tests/metagpt/tools/test_iflytek_tts.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/12/26
@Author : mashenquan
@File : test_iflytek_tts.py
"""
import pytest
from metagpt.config2 import config
from metagpt.tools.iflytek_tts import IFlyTekTTS, oas3_iflytek_tts
@pytest.mark.asyncio
async def test_iflytek_tts(mocker):
# mock
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_azure_tts.py | tests/metagpt/tools/test_azure_tts.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/7/1 22:50
@Author : alexanderwu
@File : test_azure_tts.py
@Modified By: mashenquan, 2023-8-9, add more text formatting options
@Modified By: mashenquan, 2023-8-17, move to `tools` folder.
"""
from pathlib import Path
import pytest
from azure.cogniti... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_summarize.py | tests/metagpt/tools/test_summarize.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/2 17:46
@Author : alexanderwu
@File : test_summarize.py
"""
import pytest
CASES = [
"""# 上下文
[{'title': '抗痘 / 控油 / 毛孔調理 臉部保養 商品 | 屈臣氏 Watsons', 'href': 'https://www.watsons.com.tw/%E8%87%89%E9%83%A8%E4%BF%9D%E9%A4%8A/%E6%8A%97%E7%97%98-%E6%8E... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_search_engine_meilisearch.py | tests/metagpt/tools/test_search_engine_meilisearch.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/27 22:18
@Author : alexanderwu
@File : test_search_engine_meilisearch.py
"""
import subprocess
import time
import pytest
from metagpt.logs import logger
from metagpt.tools.search_engine_meilisearch import DataSource, MeilisearchEngine
MASTER_KEY... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_translate.py | tests/metagpt/tools/test_translate.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/2 17:46
@Author : alexanderwu
@File : test_translate.py
"""
import pytest
from metagpt.logs import logger
from metagpt.tools.translator import Translator
@pytest.mark.asyncio
@pytest.mark.usefixtures("llm_api")
async def test_translate(llm_api)... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_tool_recommend.py | tests/metagpt/tools/test_tool_recommend.py | import pytest
from metagpt.schema import Plan, Task
from metagpt.tools import TOOL_REGISTRY
from metagpt.tools.tool_recommend import (
BM25ToolRecommender,
ToolRecommender,
TypeMatchToolRecommender,
)
@pytest.fixture
def mock_plan(mocker):
task_map = {
"1": Task(
task_id="1",
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_moderation.py | tests/metagpt/tools/test_moderation.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/9/26 14:46
@Author : zhanglei
@File : test_moderation.py
"""
import pytest
from metagpt.config2 import config
from metagpt.llm import LLM
from metagpt.tools.moderation import Moderation
@pytest.mark.asyncio
@pytest.mark.parametrize(
("content... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_tool_convert.py | tests/metagpt/tools/test_tool_convert.py | from typing import Literal, Union
import pandas as pd
from metagpt.tools.tool_convert import (
convert_code_to_tool_schema,
convert_code_to_tool_schema_ast,
)
class DummyClass:
"""
Completing missing values with simple strategies.
"""
def __init__(self, features: list, strategy: str = "mean... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_ut_writer.py | tests/metagpt/tools/test_ut_writer.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/4/30 21:44
@Author : alexanderwu
@File : test_ut_writer.py
"""
from pathlib import Path
import pytest
from openai.resources.chat.completions import AsyncCompletions
from openai.types import CompletionUsage
from openai.types.chat.chat_completion impo... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_openapi_v3_hello.py | tests/metagpt/tools/test_openapi_v3_hello.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/12/26
@Author : mashenquan
@File : test_openapi_v3_hello.py
"""
import asyncio
import subprocess
from pathlib import Path
import pytest
import requests
@pytest.mark.asyncio
async def test_hello(context):
workdir = Path(__file__).parent.parent.... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_web_browser_engine_selenium.py | tests/metagpt/tools/test_web_browser_engine_selenium.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import browsers
import pytest
from metagpt.tools import web_browser_engine_selenium
from metagpt.utils.parse_html import WebPage
@pytest.mark.asyncio
@pytest.mark.parametrize(
"browser_type, use_proxy,",
[
pytest.param(
"chrome",
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_metagpt_text_to_image.py | tests/metagpt/tools/test_metagpt_text_to_image.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/12/26
@Author : mashenquan
@File : test_metagpt_text_to_image.py
"""
import base64
from unittest.mock import AsyncMock
import pytest
from metagpt.config2 import config
from metagpt.tools.metagpt_text_to_image import oas3_metagpt_text_to_image
@py... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/__init__.py | tests/metagpt/tools/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/4/29 16:27
@Author : alexanderwu
@File : __init__.py
"""
| python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_openai_text_to_embedding.py | tests/metagpt/tools/test_openai_text_to_embedding.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/12/26
@Author : mashenquan
@File : test_openai_text_to_embedding.py
"""
import json
from pathlib import Path
import pytest
from metagpt.config2 import config
from metagpt.tools.openai_text_to_embedding import oas3_openai_text_to_embedding
from meta... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_openai_text_to_image.py | tests/metagpt/tools/test_openai_text_to_image.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/12/26
@Author : mashenquan
@File : test_openai_text_to_image.py
"""
import base64
import openai
import pytest
from pydantic import BaseModel
from metagpt.config2 import config
from metagpt.llm import LLM
from metagpt.tools.openai_text_to_image impo... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_metagpt_oas3_api_svc.py | tests/metagpt/tools/test_metagpt_oas3_api_svc.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/12/26
@Author : mashenquan
@File : test_metagpt_oas3_api_svc.py
"""
import asyncio
import subprocess
from pathlib import Path
import pytest
import requests
@pytest.mark.asyncio
async def test_oas2_svc(context):
workdir = Path(__file__).parent.... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_tool_registry.py | tests/metagpt/tools/test_tool_registry.py | import pytest
from metagpt.tools.tool_registry import ToolRegistry
@pytest.fixture
def tool_registry():
return ToolRegistry()
# Test Initialization
def test_initialization(tool_registry):
assert isinstance(tool_registry, ToolRegistry)
assert tool_registry.tools == {}
assert tool_registry.tools_by_t... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/test_search_engine.py | tests/metagpt/tools/test_search_engine.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/2 17:46
@Author : alexanderwu
@File : test_search_engine.py
"""
from __future__ import annotations
from typing import Callable
import pytest
from metagpt.configs.search_config import SearchConfig
from metagpt.logs import logger
from metagpt.tool... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_env.py | tests/metagpt/tools/libs/test_env.py | import os
from unittest.mock import AsyncMock
import pytest
from metagpt.tools.libs.env import (
EnvKeyNotFoundError,
default_get_env_description,
get_env,
get_env_default,
set_get_env_entry,
)
@pytest.mark.asyncio
class TestEnv:
@pytest.fixture(autouse=True)
def setup_and_teardown(self)... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_gpt_v_generator.py | tests/metagpt/tools/libs/test_gpt_v_generator.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2024/01/15
@Author : mannaandpoem
@File : test_gpt_v_generator.py
"""
from pathlib import Path
import pytest
from metagpt import logs
from metagpt.const import METAGPT_ROOT
from metagpt.tools.libs.gpt_v_generator import GPTvGenerator
@pytest.fixture
d... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_software_development.py | tests/metagpt/tools/libs/test_software_development.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from typing import Dict
import pytest
from metagpt.tools.libs.software_development import import_git_repo
async def get_env_description() -> Dict[str, str]:
return {'await get_env(key="access_token", app_name="github")': "get the access token for github authenticati... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_data_preprocess.py | tests/metagpt/tools/libs/test_data_preprocess.py | from datetime import datetime
import numpy as np
import numpy.testing as npt
import pandas as pd
import pytest
from metagpt.tools.libs.data_preprocess import (
FillMissingValue,
LabelEncode,
MaxAbsScale,
MinMaxScale,
OneHotEncode,
OrdinalEncode,
RobustScale,
StandardScale,
get_colu... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_git.py | tests/metagpt/tools/libs/test_git.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import annotations
import os
import uuid
import pytest
from github import Auth, Github
from pydantic import BaseModel
from metagpt.context import Context
from metagpt.roles.di.data_interpreter import DataInterpreter
from metagpt.schema import UserMessage
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_browser.py | tests/metagpt/tools/libs/test_browser.py | from unittest.mock import AsyncMock, patch
import pytest
import pytest_asyncio
from metagpt.const import TEST_DATA_PATH
from metagpt.tools.libs.browser import Browser
TEST_URL = "https://docs.deepwisdom.ai/main/en/guide/get_started/quickstart.html"
TEST_SCREENSHOT_PATH = TEST_DATA_PATH / "screenshot.png"
@pytest.... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_linter.py | tests/metagpt/tools/libs/test_linter.py | import tempfile
from pathlib import Path
import pytest
from metagpt.tools.libs.linter import Linter, LintResult
def test_linter_initialization():
linter = Linter(encoding="utf-8", root="/test/root")
assert linter.encoding == "utf-8"
assert linter.root == "/test/root"
assert "python" in linter.langua... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_editor.py | tests/metagpt/tools/libs/test_editor.py | import os
import shutil
from pathlib import Path
import pytest
from metagpt.const import TEST_DATA_PATH
from metagpt.tools.libs.editor import Editor
from metagpt.tools.libs.index_repo import (
CHATS_INDEX_ROOT,
CHATS_ROOT,
DEFAULT_MIN_TOKEN_COUNT,
UPLOAD_ROOT,
IndexRepo,
)
from metagpt.utils.commo... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_sd_engine.py | tests/metagpt/tools/libs/test_sd_engine.py | # -*- coding: utf-8 -*-
# @Date : 1/10/2024 10:07 PM
# @Author : stellahong (stellahong@fuzhi.ai)
# @Desc :
import base64
import io
import json
import pytest
from PIL import Image, ImageDraw
from metagpt.tools.libs.sd_engine import SDEngine
def generate_mock_image_data():
# 创建一个简单的图片对象
image = Image.... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_web_scraping.py | tests/metagpt/tools/libs/test_web_scraping.py | import pytest
from metagpt.tools.libs.web_scraping import view_page_element_to_scrape
@pytest.mark.asyncio
async def test_view_page_element_to_scrape():
# Define the test URL and parameters
test_url = "https://docs.deepwisdom.ai/main/zh/"
test_requirement = "Retrieve all paragraph texts"
test_keep_li... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/__init__.py | tests/metagpt/tools/libs/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2024/1/11 16:14
# @Author : lidanyang
# @File : __init__.py
# @Desc :
| python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_terminal.py | tests/metagpt/tools/libs/test_terminal.py | import pytest
from metagpt.const import DATA_PATH, METAGPT_ROOT
from metagpt.tools.libs.terminal import Terminal
@pytest.mark.asyncio
async def test_terminal():
terminal = Terminal()
await terminal.run_command(f"cd {METAGPT_ROOT}")
output = await terminal.run_command("pwd")
assert output.strip() == ... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_shell.py | tests/metagpt/tools/libs/test_shell.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import pytest
from metagpt.tools.libs.shell import shell_execute
@pytest.mark.asyncio
@pytest.mark.parametrize(
["command", "expect_stdout", "expect_stderr"],
[
(["file", f"{__file__}"], "Python script text executable, ASCII text", ""),
(f"file {_... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_index_repo.py | tests/metagpt/tools/libs/test_index_repo.py | import shutil
from pathlib import Path
import pytest
from metagpt.const import DEFAULT_WORKSPACE_ROOT, TEST_DATA_PATH
from metagpt.tools.libs.index_repo import (
CHATS_INDEX_ROOT,
UPLOADS_INDEX_ROOT,
IndexRepo,
)
@pytest.mark.skip
@pytest.mark.asyncio
@pytest.mark.parametrize(("path", "query"), [(TEST_D... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_cr.py | tests/metagpt/tools/libs/test_cr.py | import json
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
import pytest_asyncio
from metagpt.tools.libs.cr import CodeReview
class MockFile:
def __init__(self, content):
self.content = content
async def __aenter__(self):
return self
async def __aexit__(self, exc_t... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_feature_engineering.py | tests/metagpt/tools/libs/test_feature_engineering.py | import numpy as np
import pandas as pd
import pytest
from sklearn.datasets import fetch_california_housing, load_breast_cancer, load_iris
from metagpt.tools.libs.feature_engineering import (
CatCount,
CatCross,
ExtractTimeComps,
GeneralSelection,
GroupStat,
KFoldTargetMeanEncoder,
Polynomia... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_email_login.py | tests/metagpt/tools/libs/test_email_login.py | from metagpt.tools.libs.email_login import email_login_imap
def test_email_login(mocker):
mock_mailbox = mocker.patch("metagpt.tools.libs.email_login.MailBox.login")
mock_mailbox.login.return_value = mocker.Mock()
email_login_imap("test@outlook.com", "test_password")
| python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/tools/libs/test_image_getter.py | tests/metagpt/tools/libs/test_image_getter.py | from pathlib import Path
from unittest.mock import AsyncMock, patch
import pytest
import pytest_asyncio
from metagpt.tools.libs.image_getter import ImageGetter
@pytest.mark.asyncio
class TestImageGetter:
@pytest_asyncio.fixture(autouse=True)
async def image_getter_client(self):
"""Fixture to initial... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/tests/metagpt/document_store/test_chromadb_store.py | tests/metagpt/document_store/test_chromadb_store.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/6/6 00:41
@Author : alexanderwu
@File : test_chromadb_store.py
"""
from metagpt.document_store.chromadb_store import ChromaStore
# @pytest.mark.skip()
def test_chroma_store():
"""FIXME:chroma使用感觉很诡异,一用Python就挂,测试用例里也是"""
# 创建 ChromaStore 实例... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.