def test_resolve(self, tmp_pathplus: PathPlus):
		(tmp_pathplus / "README.txt").write_clean("This is the README")

		readme = Readme(file=tmp_pathplus / "README.txt", content_type="text/plain")
		assert readme.file == tmp_pathplus / "README.txt"
		assert readme.content_type == "text/plain"
		assert readme.text is None

		resolved_readme = readme.resolve()
		assert readme is not resolved_readme

		assert resolved_readme.file == tmp_pathplus / "README.txt"
		assert resolved_readme.content_type == "text/plain"
		assert resolved_readme.text == "This is the README\n"
	def test_from_file_charset(self, tmp_pathplus: PathPlus):
		(tmp_pathplus / "README.md").write_clean("This is the README", encoding="cp1252")

		readme = Readme.from_file(tmp_pathplus / "README.md", charset="cp1252")
		assert readme.file == tmp_pathplus / "README.md"
		assert readme.content_type == "text/markdown"
		assert readme.text is None

		readme.resolve(inplace=True)
		assert readme.file == tmp_pathplus / "README.md"
		assert readme.content_type == "text/markdown"
		assert readme.text == "This is the README\n"
	def test_from_file_bad_filetype(self, tmp_pathplus: PathPlus):
		with pytest.raises(ValueError, match="Unrecognised filetype for '.*README'"):
			Readme.from_file(tmp_pathplus / "README")
		with pytest.raises(ValueError, match="Unrecognised filetype for '.*README.rtf'"):
			Readme.from_file(tmp_pathplus / "README.rtf")
		with pytest.raises(ValueError, match="Unrecognised filetype for '.*README.doc'"):
			Readme.from_file(tmp_pathplus / "README.doc")
	def test_from_file(self, tmp_pathplus: PathPlus):
		(tmp_pathplus / "README.rst").write_clean("This is the README")

		readme = Readme.from_file(tmp_pathplus / "README.rst")
		assert readme.file == tmp_pathplus / "README.rst"
		assert readme.content_type == "text/x-rst"
		assert readme.text is None

		readme.resolve(inplace=True)
		assert readme.file == tmp_pathplus / "README.rst"
		assert readme.content_type == "text/x-rst"
		assert readme.text == "This is the README\n"

		(tmp_pathplus / "README.txt").write_clean("This is the README")

		readme = Readme.from_file(tmp_pathplus / "README.txt")
		assert readme.file == tmp_pathplus / "README.txt"
		assert readme.content_type == "text/plain"
		assert readme.text is None

		readme.resolve(inplace=True)
		assert readme.file == tmp_pathplus / "README.txt"
		assert readme.content_type == "text/plain"
		assert readme.text == "This is the README\n"
	def test_invalid_content_types(self):
		with pytest.raises(ValueError, match="Unsupported readme content-type 'application/json'"):
			Readme(text="This is the readme", content_type="application/json")  # type: ignore[arg-type]

		with pytest.raises(ValueError, match="Unsupported readme content-type 'image/jpeg'"):
			Readme(file="photo.jpg", content_type="image/jpeg")  # type: ignore[arg-type]
	def test_content_type_sole_arg(self):

		match = "'content_type' cannot be provided on its own; please provide either 'text' or 'file' or use the 'from_file' method."

		with pytest.raises(ValueError, match=match):
			Readme(content_type="text/x-rst")
	def test_to_pep621_dict(self, tmp_pathplus: PathPlus):
		(tmp_pathplus / "README.rst").write_clean("This is the README")

		readme = Readme(file=tmp_pathplus / "README.rst", content_type="text/x-rst")

		assert readme.to_pep621_dict() == {
				"file": f"{tmp_pathplus.as_posix()}/README.rst",
				}

		# TODO: the type ignore needs the TypedDict function fix in typing-extensions
		assert Readme.from_dict(readme.to_pep621_dict()) == readme  # type: ignore[arg-type]

		(tmp_pathplus / "README.md").write_clean("This is the README")

		readme = Readme(file=tmp_pathplus / "README.md", content_type="text/x-rst")

		assert readme.to_pep621_dict() == {
				"file": f"{tmp_pathplus.as_posix()}/README.md",
				"content-type": "text/x-rst",
				}

		# TODO: the type ignore needs the TypedDict function fix in typing-extensions
		assert Readme.from_dict(readme.to_pep621_dict()) == readme  # type: ignore[arg-type]

		(tmp_pathplus / "README.rst").write_clean("This is the README", encoding="cp1252")

		readme = Readme(file=tmp_pathplus / "README.rst", content_type="text/x-rst", charset="cp1252")

		assert readme.to_pep621_dict() == {
				"file": f"{tmp_pathplus.as_posix()}/README.rst",
				"charset": "cp1252",
				}

		# TODO: the type ignore needs the TypedDict function fix in typing-extensions
		assert Readme.from_dict(readme.to_pep621_dict()) == readme  # type: ignore[arg-type]

		readme = Readme(text="This is the README", content_type="text/x-rst")

		assert readme.to_pep621_dict() == {
				"text": "This is the README",
				"content-type": "text/x-rst",
				}

		# TODO: the type ignore needs the TypedDict function fix in typing-extensions
		assert Readme.from_dict(readme.to_pep621_dict()) == readme  # type: ignore[arg-type]
	def test_to_dict(self, tmp_pathplus: PathPlus):
		(tmp_pathplus / "README.rst").write_clean("This is the README")

		readme = Readme(file=tmp_pathplus / "README.rst", content_type="text/x-rst")

		assert readme.to_dict() == {
				"file": f"{tmp_pathplus.as_posix()}/README.rst",
				"content_type": "text/x-rst",
				}
		assert Readme.from_dict(readme.to_dict()) == readme
		assert Readme(**readme.to_dict()) == readme

		(tmp_pathplus / "README.rst").write_clean("This is the README", encoding="cp1252")

		readme = Readme(file=tmp_pathplus / "README.rst", content_type="text/x-rst", charset="cp1252")

		assert readme.to_dict() == {
				"file": f"{tmp_pathplus.as_posix()}/README.rst",
				"content_type": "text/x-rst",
				"charset": "cp1252",
				}
		assert Readme.from_dict(readme.to_dict()) == readme
		assert Readme(**readme.to_dict()) == readme

		readme = Readme(text="This is the README", content_type="text/x-rst")

		assert readme.to_dict() == {
				"text": "This is the README",
				"content_type": "text/x-rst",
				}
		assert Readme.from_dict(readme.to_dict()) == readme
		assert Readme(**readme.to_dict()) == readme
	def test_no_test_or_file(self):
		with pytest.raises(TypeError, match="At least one of 'text' and 'file' must be supplied to .*"):
			Readme()

		with pytest.raises(TypeError, match="At least one of 'text' and 'file' must be supplied to .*"):
			Readme(charset="UTF-8")