32 种文件格式,每一种都按精确大小生成
它们每一个都是该格式的真实文件。它能在对应软件中打开,字节数恰好等于你的要求。没有一个是粘上扩展名的填充零。
| 格式 | 名称 | 扩展名 | 最小文件 | 完整度 | 验证方式 |
|---|---|---|---|---|---|
avif |
AV1 Image File Format | .avif |
311 | full | pillow |
bmp |
Windows Bitmap | .bmp |
58 | full | pillow |
csv |
Comma-Separated Values | .csv |
115 | full | python-csv |
docx |
Word (Office Open XML) | .docx |
1220 | full | libreoffice |
eml |
Email message | .eml |
289 | full | python-email |
geojson |
GeoJSON | .geojson |
875 | full | gdal-geojson |
gif |
Graphics Interchange Format | .gif |
114 | full | pillow |
html |
HyperText Markup Language | .html |
122 | full | python-html |
ico |
Windows Icon | .ico |
70 | full | pillow |
jpg |
JPEG | .jpg |
602 | full | pillow |
json |
JavaScript Object Notation | .json |
219 | full | node-json |
jxl |
JPEG XL | .jxl |
147 | full | pillow-jxl |
log |
Server and application log | .log |
155 | full | 不适用 |
md |
Markdown | .md |
0 | full | 不适用 |
mp4 |
MP4 video | .mp4 |
3312 | full | libaom |
otlp |
OpenTelemetry Protocol JSON | .jsonl .json |
1266 | full | otelcol |
pdf |
Portable Document Format | .pdf |
3415 | full | pdftotext |
png |
Portable Network Graphics | .png |
74 | full | pillow |
pptx |
PowerPoint (Office Open XML) | .pptx |
4809 | full | libreoffice |
rtf |
Rich Text Format | .rtf |
65 | full | pandoc-rtf |
svg |
Scalable Vector Graphics | .svg |
194 | full | inkscape |
targz |
tar + gzip | .tar.gz |
9790 | full | 7z |
tiff |
Tagged Image File Format | .tiff |
183 | full | pillow |
toml |
TOML | .toml |
212 | full | python-toml |
txt |
Plain text | .txt |
0 | full | 不适用 |
wav |
Waveform Audio | .wav |
98 | full | ffprobe |
webm |
WebM video | .webm |
3284 | full | libaom |
webp |
WebP | .webp |
148 | full | pillow |
xlsx |
Excel (Office Open XML) | .xlsx |
1726 | full | libreoffice |
xml |
Extensible Markup Language | .xml |
264 | full | python-xml |
yaml |
YAML | .yaml |
241 | full | python-yaml |
zip |
ZIP | .zip |
8382 | full | 7z |
各列的含义
-
最小文件
本工具对该格式接受的最少字节数,包括它写在文件里的标签。请求更小的值,你会得到说明下限及其原因的错误,绝不会得到大小错误的文件。
-
完整度
文件有多完整。
full表示真正解析该格式的读取器会接受它,而不只是扩展名匹配。 -
验证方式
在格式发布之前打开每个生成文件的独立读取器,它是另一套独立实现,而不是我们自己的代码给自己批改作业。
每种格式也都能精确到字节地重复:相同的配方和种子在任何机器上都生成相同的文件,这正是提交配方来代替 fixture 本身是安全的原因。
每种格式接受的设置
大多数格式有自己的设置,比如图片尺寸、JPEG 质量、PDF 页数、电子表格的行数和列数、压缩包里放多少条目。在命令行用 --set key=value 设置,或在配方的
properties: 下设置。
tfg generate --format jpg --size 500kb --set width=1920 --set height=1080 --set quality=85
| 格式 | 设置 | 接受 |
|---|---|---|
avif |
width |
1 - 16384 像素 |
height |
1 - 16384 像素 | |
quality |
1 - 100 | |
bmp |
width |
1 - 20000 像素 |
height |
1 - 20000 像素 | |
csv |
delimiter |
comma, pipe, semicolon, tab |
line_ending |
crlf, lf | |
header |
真或假 | |
quote_style |
all, minimal, none | |
columns |
2 - 32768 列 | |
docx |
paragraphs |
1 - 50000 段落 |
eml |
body |
alternative, html, plain |
layout |
newsletter, simple | |
text_encoding |
7bit, 8bit, base64, quoted-printable | |
charset |
iso-8859-2, utf-8, windows-1250 | |
headers |
ascii, encoded, utf8 | |
recipients |
1 - 100000 | |
line_endings |
crlf, lf | |
attachments |
0 - 10000 | |
attachment_format |
格式的 id,与 tfg formats 列出的一致 | |
attachment_size |
形如 2mb 的大小 | |
filename_style |
both, content-type, none, rfc2047, rfc2231 | |
message_depth |
1 - 2000 | |
inline |
0 - 10000 | |
inline_format |
图片格式的 id,与 tfg formats 列出的一致 | |
inline_size |
形如 2mb 的大小 | |
geojson |
geometry |
geometrycollection, linestring, mixed, multilinestring, multipoint, multipolygon, point, polygon |
formatting |
indented, minified, record-per-line | |
precision |
0 - 15 位小数 | |
altitude |
真或假 | |
vertices |
3 - 1000000 个点 | |
holes |
0 - 100000 个洞 | |
winding |
reversed, rfc7946 | |
antimeridian |
真或假 | |
unlocated |
all, none, some | |
ids |
mixed, none, number, string | |
bbox |
真或假 | |
gif |
width |
1 - 20000 像素 |
height |
1 - 20000 像素 | |
frames |
1 - 60 | |
html |
structure |
document, fragment |
nesting |
0 - 100000 | |
characters |
ascii, international | |
elements |
basic, every | |
links |
0 - 1000000 | |
bom |
真或假 | |
formatting |
indented, lines, minified | |
styles |
embedded, inline, none | |
inline |
0 - 10000 | |
inline_format |
图片格式的 id,与 tfg formats 列出的一致 | |
inline_size |
形如 2mb 的大小 | |
ico |
width |
1 - 256 像素 |
height |
1 - 256 像素 | |
embed |
bmp, png | |
jpg |
width |
1 - 20000 像素 |
height |
1 - 20000 像素 | |
quality |
1 - 100 | |
json |
formatting |
indented, minified, record-per-line |
jxl |
width |
1 - 16384 像素 |
height |
1 - 16384 像素 | |
quality |
1 - 100 | |
log |
entry_format |
apache-combined, apache-common, json-lines, nginx, plain, syslog |
timestamps |
advancing, fixed | |
rate |
1 - 1000000 条目每秒 | |
methods |
get, mixed, read | |
status_mix |
client-errors, realistic, server-errors, success | |
level_mix |
debug, errors, quiet, realistic | |
ip_version |
mixed, v4, v6 | |
line_ending |
crlf, lf | |
md |
encoding |
utf-16be, utf-16le, utf-8 |
bom |
真或假 | |
mp4 |
width |
1 - 16384 像素 |
height |
1 - 16384 像素 | |
duration |
形如 10s 的时长 | |
change_interval |
形如 10s 的时长 | |
frame_rate |
1, 5, 10, 12, 15, 24, 25, 30, 48, 50, 60 | |
keyframe_interval |
形如 10s 的时长 | |
quality |
1 - 100 | |
otlp |
signal |
logs, metrics, traces |
formatting |
indented, minified, record-per-line | |
bom |
真或假 | |
batch |
1 - 1000 | |
start |
形如 2026-08-01T12:00:00Z 的 UTC 时刻 | |
rate |
1 - 1000000 条目每秒 | |
depth |
1 - 100 | |
status_mix |
client-errors, realistic, server-errors, success | |
level_mix |
debug, errors, quiet, realistic | |
trace_context |
真或假 | |
metric_kind |
exponential-histogram, gauge, histogram, mixed, sum, summary | |
temporality |
cumulative, delta | |
exemplars |
真或假 | |
interval |
1 - 86400 秒 | |
id_encoding |
base64, hex, upper-hex | |
enum_encoding |
name, number | |
key_case |
camel, snake | |
large_numbers |
number, text | |
time_order |
in-order, out-of-order | |
end_before_start |
真或假 | |
empty_envelope |
真或假 | |
body |
any-value, text | |
non_finite |
真或假 | |
pdf |
pages |
1 - 5000 |
page_size |
a3, a4, a5, legal, letter, mixed | |
orientation |
landscape, mixed, portrait | |
rotate |
0, 90, 180, 270 | |
pdf_version |
1.4, 1.7 | |
title |
任意文本 | |
author |
任意文本 | |
subject |
任意文本 | |
keywords |
任意文本 | |
creator |
任意文本 | |
producer |
任意文本 | |
created |
形如 2024-02-29 或 2024-02-29T13:45:00+02:00 的日期,或 none | |
modified |
形如 2024-02-29 或 2024-02-29T13:45:00+02:00 的日期,或 none | |
png |
width |
1 - 20000 像素 |
height |
1 - 20000 像素 | |
pptx |
slides |
1 - 500 幻灯片 |
rtf |
characters |
ascii, international |
text_encoding |
both, codepage, literal, unicode | |
elements |
basic, every | |
nesting |
0 - 10000000 | |
links |
0 - 1000000 | |
inline |
0 - 10000 | |
inline_format |
图片格式的 id,与 tfg formats 列出的一致 | |
inline_size |
形如 2mb 的大小 | |
picture_data |
binary, hex | |
svg |
width |
1 - 20000 像素 |
height |
1 - 20000 像素 | |
targz |
entries |
0 - 10000 |
entry_format |
格式的 id,与 tfg formats 列出的一致 | |
entry_size |
形如 2mb 的大小 | |
compression |
best, default, fast, none | |
depth |
0 - 50 | |
directory_entries |
真或假 | |
entry_mode |
000, 400, 444, 600, 644, 664, 666, 700, 755, 777 | |
entry_owner |
root, unset, user | |
tiff |
width |
1 - 20000 像素 |
height |
1 - 20000 像素 | |
txt |
encoding |
utf-16be, utf-16le, utf-8 |
bom |
真或假 | |
wav |
sample_rate |
8000 - 192000 赫兹 |
bit_depth |
8, 16, 24, 32 | |
channels |
1 - 8 | |
content |
noise, silence, sweep, tone | |
webm |
width |
1 - 16384 像素 |
height |
1 - 16384 像素 | |
duration |
形如 10s 的时长 | |
change_interval |
形如 10s 的时长 | |
frame_rate |
1, 5, 10, 12, 15, 24, 25, 30, 48, 50, 60 | |
keyframe_interval |
形如 10s 的时长 | |
quality |
1 - 100 | |
webp |
width |
1 - 16383 像素 |
height |
1 - 16383 像素 | |
xlsx |
rows |
1 - 200000 行 |
columns |
1 - 32768 列 | |
xml |
encoding |
utf-16be, utf-16le, utf-8 |
bom |
真或假 | |
zip |
entries |
0 - 10000 |
entry_format |
格式的 id,与 tfg formats 列出的一致 | |
entry_size |
形如 2mb 的大小 | |
compression |
best, default, fast, none | |
depth |
0 - 50 | |
directory_entries |
真或假 | |
password |
明文密码 | |
encryption |
aes-128, aes-192, aes-256, none, zipcrypto |
超出设置所接受范围的值会被拒绝,并给出指明该设置、允许范围以及应改用什么的消息。未知的设置同样是错误,绝不会静默使用默认值,因为悄悄接受的拼写错误会生成设置有误的文件,让你花一小时纳闷为什么该失败的测试却通过了。
运行 tfg formats <id> 即可查看某个格式在你当前版本中接受哪些设置。
压缩包里装的是真实文件
eml 和 targz 和 zip
可以填入条目,而不是只留一个空壳。生成的压缩包确实包含它声称包含的文档,所以测试期间解压它的任何程序都会在里面找到真实文件。
targets:
- id: bundle
format: zip
contains:
- format: txt
count: 200
size: 4kb