From 92727f466f6a85c242e305215ea73cf57af60374 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Thu, 2 Aug 2018 13:33:37 -0500 Subject: [PATCH 1/2] Port https://github.com/rtfd/readthedocs-build/pull/38/ --- readthedocs/config/tests/test_config.py | 20 ++++++++++++++++++++ readthedocs/config/tests/test_parser.py | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/readthedocs/config/tests/test_config.py b/readthedocs/config/tests/test_config.py index ddbf59c2eac..0b96f83f5e3 100644 --- a/readthedocs/config/tests/test_config.py +++ b/readthedocs/config/tests/test_config.py @@ -737,6 +737,26 @@ def test_requirements_file_respects_configuration(tmpdir): assert build.requirements_file == 'requirements.txt' +def test_requirements_file_is_null(tmpdir): + build = get_build_config( + {'requirements_file': None}, + get_env_config(), + source_file=str(tmpdir.join('readthedocs.yml')), + ) + build.validate() + assert build.requirements_file is None + + +def test_requirements_file_is_blank(tmpdir): + build = get_build_config( + {'requirements_file': ''}, + get_env_config(), + source_file=str(tmpdir.join('readthedocs.yml')), + ) + build.validate() + assert build.requirements_file is None + + def test_build_validate_calls_all_subvalidators(tmpdir): apply_fs(tmpdir, minimal_config) build = BuildConfigV1( diff --git a/readthedocs/config/tests/test_parser.py b/readthedocs/config/tests/test_parser.py index ff116b19f36..b2f138d6c4e 100644 --- a/readthedocs/config/tests/test_parser.py +++ b/readthedocs/config/tests/test_parser.py @@ -33,6 +33,24 @@ def test_parse_single_config(): assert config[0]['base'] == 'path' +def test_parse_null_value(): + buf = StringIO(u'base: null') + config = parse(buf) + assert config[0]['base'] is None + + +def test_parse_empty_value(): + buf = StringIO(u'base:') + config = parse(buf) + assert config[0]['base'] is None + + +def test_parse_empty_string_value(): + buf = StringIO(u'base: ""') + config = parse(buf) + assert config[0]['base'] is '' + + def test_parse_empty_list(): buf = StringIO(u'base: []') config = parse(buf) From 7ddc8eb85c84364d232a3e9f2f2d413e4165497a Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Thu, 2 Aug 2018 14:37:39 -0500 Subject: [PATCH 2/2] Fix test --- readthedocs/config/tests/test_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/config/tests/test_parser.py b/readthedocs/config/tests/test_parser.py index b2f138d6c4e..afdc8dde41d 100644 --- a/readthedocs/config/tests/test_parser.py +++ b/readthedocs/config/tests/test_parser.py @@ -48,7 +48,7 @@ def test_parse_empty_value(): def test_parse_empty_string_value(): buf = StringIO(u'base: ""') config = parse(buf) - assert config[0]['base'] is '' + assert config[0]['base'] == '' def test_parse_empty_list():