Is There a Speaker of the House Yet?
isthereaspeakerofthehouseyet.com3 pointsby MadVikingGod2 comments
// code.go
var now = time.Now
// code_test.go
func TestCode(t *testing.T) {
nowSwap := now
t.Cleanup (func() {
now = nowSwap
}
now = func() time.Time {
return time.Date(...)
}
}
Examples
Code: https://github.com/open-telemetry/opentelemetry-go/blob/main...
Test: https://github.com/open-telemetry/opentelemetry-go/blob/490f... class _:
def __neg__(self):
return -1
def __sub__(self, other):
return 1-other
You get similar behavior: >>> --_()
1
>>> _()--_()
2
Fun python for everyone.
[1]: https://www.gnu.org/licenses/agpl-3.0.txt
[2]: https://github.com/ONLYOFFICE/core/blob/master/LICENSE.txt
[3]: https://github.com/ONLYOFFICE/onlyoffice-nextcloud/blob/mast...