コード例 #1
0
def test_verbose_setter_invalid(capsys):
    """ GithubReports Class 'verbose' Property Setter Invalid Value Test

    This test will test the verbose getter and setter property methods.
    Default value tested during init test, test setting value to invalid value
    using the property setter method.

    Expected Result:
      'verbose' property should be set to False, ignoring the invalid value.
    """

    # Instantiate a GithubReports object, and test for expected test values.
    GitHubReportObj = GithubReports()
    assert (isinstance(GitHubReportObj, object))

    # Test verbose setting was defaulted to False
    assert (not GitHubReportObj._verbose)
    assert (not GitHubReportObj.verbose)

    # Set verbose to an invalid value using property settter and test the
    # value ensuring that the invalid value was ignored, and is set False.
    GitHubReportObj.verbose = 42
    assert (not GitHubReportObj._verbose)
    assert (not GitHubReportObj.verbose)

    # Capture stdout, stderr to test log messages
    out, err = capsys.readouterr()
    # sys.stdout.write(out)
    # sys.stderr.write(err)
    assert "ERROR   CLS->GitHubReports.verbose: \
-> verbose property argument expected type bool but received type:" in err
コード例 #2
0
def test_verbose_setter_enabled():
    """ GithubReports Class 'verbose' Property Setter Test

    This test will test the verbose getter and setter property methods.
    Default value tested during init test, test setting value to True
    using the class verbose setter method.

    Expected Result:
      'verbose' property should be set to True.
    """

    # Instantiate a GithubReports object, and test for expected test values.
    GitHubReportObj = GithubReports()
    assert (isinstance(GitHubReportObj, object))

    # Test verbose is set to default False
    assert (not GitHubReportObj._verbose)
    assert (not GitHubReportObj.verbose)

    # Call the Setter to enable verbose and test the property value is True
    GitHubReportObj.verbose = True
    assert (GitHubReportObj._verbose)
    assert (GitHubReportObj.verbose)