Skip to content
Myr

Describe the progression of tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Refs: https://github.com/pallets/click/pull/3030/files#r2289225645 https://github.com/pallets/click/pull/3030/files#r2289226067 https://github.com/pallets/click/pull/3030/files#r2289226489

authored by Kevin Deldycke · committed by Kevin Deldycke · parent 354788e · Browse files · 1 file+16 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Refs:
  • https: //github.com/pallets/click/pull/3030/files#r2289225645
  • https: //github.com/pallets/click/pull/3030/files#r2289226067
  • https: //github.com/pallets/click/pull/3030/files#r2289226489

Diff stats

1 file+16 added−12 removed

  • tests:+16 added−12 removed

1 file+16 added−12 removed

modified:tests/test_options.py+16 added-12 removed
1911 unmodified lines
1912 # See: the result is the same if we force the type to be str.1913 ({"type": str, "flag_value": 1, "default": True}, [], "True"),1914 ({"type": str, "flag_value": "1", "default": True}, [], "True"),1915 ({"type": str, "flag_value": EngineType.OSS, "default": True}, [], "True"),1916 # But having the flag value set to integer is automaticcally recognized by click.1916 # But having the flag value set to integer is automaticcally recognized by Click.1917 ({"flag_value": 1, "default": True}, [], 1),1918 ({"type": int, "flag_value": 1, "default": True}, [], 1),1919 ({"type": int, "flag_value": "1", "default": True}, [], 1),1920 ],
20 unmodified lines
19411942@pytest.mark.parametrize(1943 ("opt1_params", "opt2_params", "args", "expected"),1944 [1945 ###1946 ### Reproduces https://github.com/pallets/click/issues/3024#issuecomment-31465085361947 ###1945 # Dual options sharing the same variable name, are not competitive, and the1946 # flag value is returned as-is. Especially when the type is force to be unprocessed.1947 (1948 {"flag_value": EngineType.OSS, "type": UNPROCESSED},1949 {"flag_value": EngineType.PRO, "type": UNPROCESSED},1950 [],
10 unmodified lines
1961 {"flag_value": EngineType.PRO, "type": UNPROCESSED},1962 ["--opt2"],1963 EngineType.PRO,1964 ),1966 ###1967 ### Reproduces https://github.com/pallets/click/issues/2012#issue-9464710491968 ###1969 # Default type fallback to string.1965 # Check that passing exotic flag values like classes is supported, but are rendered to strings1966 # when the type is not specified.1967 ({"flag_value": Class1, "default": True}, {"flag_value": Class2}, [], "True"),1968 (1969 {"flag_value": Class1, "default": True},1970 {"flag_value": Class2},
29 unmodified lines
2000 Class2,2001 ),2002 # Setting the default to a class, an instance of the class is returned instead2003 # of the class itself, because the default is allowed to be callable (and2007 # consummd). And this what happens the type is.2004 # consummd). And this happens whatever the type is.2005 (2006 {"flag_value": Class1, "default": Class1},2007 {"flag_value": Class2},2008 [],
16 unmodified lines
2025 {"flag_value": Class2, "type": UNPROCESSED},2026 [],2027 re.compile(r"<test_options.Class2 object at 0x[0-9A-Fa-f]+>"),2028 ),2032 ###2033 ### Reproduces https://github.com/pallets/click/issues/2012#issuecomment-8924370602034 ###2029 # Having the flag value set to integer is automaticcally recognized by Click.2030 (2031 {"flag_value": 1, "default": True},2032 {"flag_value": "1"},2033 [],
9 unmodified lines
2043)2044def test_custom_type_flag_value_dual_options(2045 runner, opt1_params, opt2_params, args, expected2046):2047 """Test how flag values are processed with dual options competing for the same2048 variable name.20492050 Reproduce issues reported in:2051 https://github.com/pallets/click/issues/3024#issuecomment-31465085362052 https://github.com/pallets/click/issues/2012#issue-9464710492053 https://github.com/pallets/click/issues/2012#issuecomment-8924370602054 """20552056 @click.command()2057 @click.option("--opt1", "dual_option", **opt1_params)2058 @click.option("--opt2", "dual_option", **opt2_params)2059 def cli(dual_option):
31 unmodified lines