{"modulePath":"github.com/raspberrypython/testify","version":"v0.0.0-20150620232711-089c7181b8c7","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package require\n\nAlternative testing tools which stop test execution if test failed.\n\n### Example Usage {#hdr-Example_Usage}\n\nThe following is a complete example using require in a standard test function:\n\n\timport (\n\t  \"testing\"\n\t  \"github.com/stretchr/testify/require\"\n\t)\n\n\tfunc TestSomething(t *testing.T) {\n\n\t  var a string = \"Hello\"\n\t  var b string = \"Hello\"\n\n\t  require.Equal(t, a, b, \"The two words should be the same.\")\n\n\t}\n\n### Assertions {#hdr-Assertions}\n\nThe \\`require\\` package have same global functions as in the \\`assert\\` package, but instead of returning a boolean result they call \\`t.FailNow()\\`.\n\nEvery assertion function also takes an optional string message as the final argument, allowing custom error messages to be appended to the message the assertion method outputs.\n\nHere is an overview of the assert functions:\n\n\t   require.Equal(t, expected, actual [, message [, format-args])\n\n\t   require.NotEqual(t, notExpected, actual [, message [, format-args]])\n\n\t   require.True(t, actualBool [, message [, format-args]])\n\n\t   require.False(t, actualBool [, message [, format-args]])\n\n\t   require.Nil(t, actualObject [, message [, format-args]])\n\n\t   require.NotNil(t, actualObject [, message [, format-args]])\n\n\t   require.Empty(t, actualObject [, message [, format-args]])\n\n\t   require.NotEmpty(t, actualObject [, message [, format-args]])\n\n\t   require.Error(t, errorObject [, message [, format-args]])\n\n\t   require.NoError(t, errorObject [, message [, format-args]])\n\n\t   require.EqualError(t, theError, errString [, message [, format-args]])\n\n\t   require.Implements(t, (*MyInterface)(nil), new(MyObject) [,message [, format-args]])\n\n\t   require.IsType(t, expectedObject, actualObject [, message [, format-args]])\n\n\t   require.Contains(t, string, substring [, message [, format-args]])\n\n\t   require.NotContains(t, string, substring [, message [, format-args]])\n\n\t   require.Panics(t, func(){\n\n\t\t    // call code that should panic\n\n\t   } [, message [, format-args]])\n\n\t   require.NotPanics(t, func(){\n\n\t\t    // call code that should not panic\n\n\t   } [, message [, format-args]])\n\n\t   require.WithinDuration(t, timeA, timeB, deltaTime, [, message [, format-args]])\n\n\t   require.InDelta(t, numA, numB, delta, [, message [, format-args]])\n\n\t   require.InEpsilon(t, numA, numB, epsilon, [, message [, format-args]])\n\n## Functions\n\n```go\nfunc Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{})\n```\nCondition uses a Comparison to assert a complex condition.\n\n```go\nfunc Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{})\n```\nContains asserts that the specified string contains the specified substring.\n\n\trequire.Contains(t, \"Hello World\", \"World\", \"But 'Hello World' does contain 'World'\")\n\n```go\nfunc Empty(t TestingT, object interface{}, msgAndArgs ...interface{})\n```\nEmpty asserts that the specified object is empty.  I.e. nil, \"\", false, 0 or either a slice or a channel with len == 0.\n\nrequire.Empty(t, obj)\n\n```go\nfunc Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{})\n```\nEqual asserts that two objects are equal.\n\n\trequire.Equal(t, 123, 123, \"123 and 123 should be equal\")\n\n```go\nfunc EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{})\n```\nEqualError asserts that a function returned an error (i.e. not \\`nil\\`) and that it is equal to the provided error.\n\n\tactualObj, err := SomeFunction()\n\trequire.Error(t, err, \"An error was expected\")\n\trequire.Equal(t, err, expectedError)\n\t}\n\n```go\nfunc EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{})\n```\nEqualValues asserts that two objects are equal or convertable to each other.\n\n\trequire.EqualValues(t, uint32(123), int32(123), \"123 and 123 should be equal\")\n\n```go\nfunc Error(t TestingT, err error, msgAndArgs ...interface{})\n```\nError asserts that a function returned an error (i.e. not \\`nil\\`).\n\n\tactualObj, err := SomeFunction()\n\trequire.Error(t, err, \"An error was expected\")\n\trequire.Equal(t, err, expectedError)\n\t}\n\n```go\nfunc Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{})\n```\nExactly asserts that two objects are equal is value and type.\n\n\trequire.Exactly(t, int32(123), int64(123), \"123 and 123 should NOT be equal\")\n\n```go\nfunc FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{})\n```\nFail reports a failure through\n\n```go\nfunc False(t TestingT, value bool, msgAndArgs ...interface{})\n```\nFalse asserts that the specified value is true.\n\n\trequire.False(t, myBool, \"myBool should be false\")\n\n```go\nfunc Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{})\n```\nImplements asserts that an object is implemented by the specified interface.\n\n\trequire.Implements(t, (*MyInterface)(nil), new(MyObject), \"MyObject\")\n\n```go\nfunc InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{})\n```\nInDelta asserts that the two numerals are within delta of each other.\n\n\trequire.InDelta(t, math.Pi, (22 / 7.0), 0.01)\n\n```go\nfunc InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{})\n```\nInEpsilon asserts that expected and actual have a relative error less than epsilon\n\n```go\nfunc IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{})\n```\nIsType asserts that the specified objects are of the same type.\n\n```go\nfunc Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{})\n```\nLen asserts that the specified object has specific length. Len also fails if the object has a type that len() not accept.\n\n\trequire.Len(t, mySlice, 3, \"The size of slice is not 3\")\n\n```go\nfunc Nil(t TestingT, object interface{}, msgAndArgs ...interface{})\n```\nNil asserts that the specified object is nil.\n\n\trequire.Nil(t, err, \"err should be nothing\")\n\n```go\nfunc NoError(t TestingT, err error, msgAndArgs ...interface{})\n```\nNoError asserts that a function returned no error (i.e. \\`nil\\`).\n\n\tactualObj, err := SomeFunction()\n\trequire.NoError(t, err)\n\trequire.Equal(t, actualObj, expectedObj)\n\nReturns whether the assertion was successful (true) or not (false).\n\n```go\nfunc NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{})\n```\nNotContains asserts that the specified string does NOT contain the specified substring.\n\n\trequire.NotContains(t, \"Hello World\", \"Earth\", \"But 'Hello World' does NOT contain 'Earth'\")\n\n```go\nfunc NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{})\n```\nNotEmpty asserts that the specified object is NOT empty.  I.e. not nil, \"\", false, 0 or either a slice or a channel with len == 0.\n\nrequire.NotEmpty(t, obj) require.Equal(t, \"one\", obj\\[0])\n\n```go\nfunc NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{})\n```\nNotEqual asserts that the specified values are NOT equal.\n\n\trequire.NotEqual(t, obj1, obj2, \"two objects shouldn't be equal\")\n\n```go\nfunc NotNil(t TestingT, object interface{}, msgAndArgs ...interface{})\n```\nNotNil asserts that the specified object is not nil.\n\n\trequire.NotNil(t, err, \"err should be something\")\n\n```go\nfunc NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{})\n```\nNotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.\n\n\trequire.NotPanics(t, func(){\n\t  RemainCalm()\n\t}, \"Calling RemainCalm() should NOT panic\")\n\n```go\nfunc NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{})\n```\nNotRegexp asserts that a specified regexp does not match a string.\n\n\trequire.NotRegexp(t, regexp.MustCompile(\"starts\"), \"it's starting\")\n\trequire.NotRegexp(t, \"^start\", \"it's not starting\")\n\n```go\nfunc Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{})\n```\nPanics asserts that the code inside the specified PanicTestFunc panics.\n\n\trequire.Panics(t, func(){\n\t  GoCrazy()\n\t}, \"Calling GoCrazy() should panic\")\n\n```go\nfunc Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{})\n```\nRegexp asserts that a specified regexp matches a string.\n\n\trequire.Regexp(t, regexp.MustCompile(\"start\"), \"it's starting\")\n\trequire.Regexp(t, \"start...$\", \"it's not starting\")\n\n```go\nfunc True(t TestingT, value bool, msgAndArgs ...interface{})\n```\nTrue asserts that the specified value is true.\n\n\trequire.True(t, myBool, \"myBool should be true\")\n\n```go\nfunc WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{})\n```\nWithinDuration asserts that the two times are within duration delta of each other.\n\n\trequire.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, \"The difference should not be more than 10s\")\n\n## Types\n\n```go\ntype Assertions struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc New(t TestingT) *Assertions\n```\n\n```go\nfunc (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{})\n```\nUses a Comparison to assert a complex condition.\n\n```go\nfunc (a *Assertions) Contains(s, contains interface{}, msgAndArgs ...interface{})\n```\nContains asserts that the specified string contains the specified substring.\n\n\trequire.Contains(\"Hello World\", \"World\", \"But 'Hello World' does contain 'World'\")\n\n```go\nfunc (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{})\n```\nEmpty asserts that the specified object is empty.  I.e. nil, \"\", false, 0 or a slice with len == 0.\n\nrequire.Empty(obj)\n\n```go\nfunc (a *Assertions) Equal(expected, actual interface{}, msgAndArgs ...interface{})\n```\nEqual asserts that two objects are equal.\n\n\trequire.Equal(123, 123, \"123 and 123 should be equal\")\n\n```go\nfunc (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{})\n```\nEqualError asserts that a function returned an error (i.e. not \\`nil\\`) and that it is equal to the provided error.\n\n\t  actualObj, err := SomeFunction()\n\t  if require.Error(err, \"An error was expected\") {\n\t\t   require.Equal(err, expectedError)\n\t  }\n\n```go\nfunc (a *Assertions) Error(theError error, msgAndArgs ...interface{})\n```\nError asserts that a function returned an error (i.e. not \\`nil\\`).\n\n\t  actualObj, err := SomeFunction()\n\t  if require.Error(err, \"An error was expected\") {\n\t\t   require.Equal(err, expectedError)\n\t  }\n\n```go\nfunc (a *Assertions) Exactly(expected, actual interface{}, msgAndArgs ...interface{})\n```\nExactly asserts that two objects are equal is value and type.\n\n\trequire.Exactly(int32(123), int64(123), \"123 and 123 should NOT be equal\")\n\n```go\nfunc (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{})\n```\nFail reports a failure through\n\n```go\nfunc (a *Assertions) False(value bool, msgAndArgs ...interface{})\n```\nFalse asserts that the specified value is true.\n\n\trequire.False(myBool, \"myBool should be false\")\n\n```go\nfunc (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{})\n```\n\n```go\nfunc (a *Assertions) InDelta(expected, actual interface{}, delta float64, msgAndArgs ...interface{})\n```\nInDelta asserts that the two numerals are within delta of each other.\n\n\trequire.InDelta(t, math.Pi, (22 / 7.0), 0.01)\n\n```go\nfunc (a *Assertions) InEpsilon(expected, actual interface{}, epsilon float64, msgAndArgs ...interface{})\n```\nInEpsilon asserts that expected and actual have a relative error less than epsilon\n\n```go\nfunc (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{})\n```\nIsType asserts that the specified objects are of the same type.\n\n```go\nfunc (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{})\n```\nLen asserts that the specified object has specific length. Len also fails if the object has a type that len() not accept.\n\n\trequire.Len(mySlice, 3, \"The size of slice is not 3\")\n\n```go\nfunc (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{})\n```\nNil asserts that the specified object is nil.\n\n\trequire.Nil(err, \"err should be nothing\")\n\n```go\nfunc (a *Assertions) NoError(theError error, msgAndArgs ...interface{})\n```\nNoError asserts that a function returned no error (i.e. \\`nil\\`).\n\n\t  actualObj, err := SomeFunction()\n\t  if require.NoError(err) {\n\t\t   require.Equal(actualObj, expectedObj)\n\t  }\n\n```go\nfunc (a *Assertions) NotContains(s, contains interface{}, msgAndArgs ...interface{})\n```\nNotContains asserts that the specified string does NOT contain the specified substring.\n\n\trequire.NotContains(\"Hello World\", \"Earth\", \"But 'Hello World' does NOT contain 'Earth'\")\n\n```go\nfunc (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{})\n```\nEmpty asserts that the specified object is NOT empty.  I.e. not nil, \"\", false, 0 or a slice with len == 0.\n\n\tif require.NotEmpty(obj) {\n\t  require.Equal(\"two\", obj[1])\n\t}\n\n```go\nfunc (a *Assertions) NotEqual(expected, actual interface{}, msgAndArgs ...interface{})\n```\nNotEqual asserts that the specified values are NOT equal.\n\n\trequire.NotEqual(obj1, obj2, \"two objects shouldn't be equal\")\n\n```go\nfunc (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{})\n```\nNotNil asserts that the specified object is not nil.\n\n\trequire.NotNil(err, \"err should be something\")\n\n```go\nfunc (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{})\n```\nNotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.\n\n\trequire.NotPanics(func(){\n\t  RemainCalm()\n\t}, \"Calling RemainCalm() should NOT panic\")\n\n```go\nfunc (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{})\n```\nNotRegexp asserts that a specified regexp does not match a string.\n\n\trequire.NotRegexp(t, regexp.MustCompile(\"starts\"), \"it's starting\")\n\trequire.NotRegexp(t, \"^start\", \"it's not starting\")\n\n```go\nfunc (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{})\n```\nPanics asserts that the code inside the specified PanicTestFunc panics.\n\n\trequire.Panics(func(){\n\t  GoCrazy()\n\t}, \"Calling GoCrazy() should panic\")\n\n```go\nfunc (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{})\n```\nRegexp asserts that a specified regexp matches a string.\n\n\trequire.Regexp(t, regexp.MustCompile(\"start\"), \"it's starting\")\n\trequire.Regexp(t, \"start...$\", \"it's not starting\")\n\n```go\nfunc (a *Assertions) True(value bool, msgAndArgs ...interface{})\n```\nTrue asserts that the specified value is true.\n\n\trequire.True(myBool, \"myBool should be true\")\n\n```go\nfunc (a *Assertions) WithinDuration(expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{})\n```\nWithinDuration asserts that the two times are within duration delta of each other.\n\n\trequire.WithinDuration(time.Now(), time.Now(), 10*time.Second, \"The difference should not be more than 10s\")\n\n```go\ntype TestingT interface {\n\tErrorf(format string, args ...interface{})\n\tFailNow()\n}\n```\n\n","path":"github.com/raspberrypython/testify/require","name":"require","synopsis":"Alternative testing tools which stop test execution if test failed.","isRedistributable":true}
