Package: expycted
OverviewExpyctedis yet anotherexpectpattern implementation.It is not dependent on any testing framework and can plug into any as it is just an abstraction overassert.Examples:fromexpyctedimportexpectexpect(True).to_not.be_false()# This will succeedexpect([]).to.be_empty()# This will succeedexpect([1,2,3]).to.contain(3)# This will succeedexpect(10).to.equal("10")# This will raise AssertionErrorexpect(10).to.be("10")# This will succeedexpect.function(int).to_raise(ValueError).when_called_with('a')# This will also succeedInstallationExpyctedcan be installed from PyPi by using:pipinstallexpyctedAlternatively, you can clone the repository and build your own distribution using poetry.gitclonehttps://github.com/petereon/expycted.git
poetrybuildThen you can install it using:pipinstall./dist/expycted-<version>-py3-none-any.whlMatchersMatchers are used to ensure some conditions are met.Value MatchersValue matchers can be used in two equivalent ways demonstrated below:expect.value(10).to.be_greater_than(1)expect(10).to.be_greater_than(1)Currently available matchers are:Eqality and similarityequal(self, value): equivalent to "==". With aliasbe_equal_tobe(self, value):  will check if string representation of values is same or if two objects have the same attributes or are equalNumericbe_greater_than(self, value): equivalent to ">". With aliasbe_greaterbe_lesser_than(self, value): equivalent to "<". With aliasbe_lesser,be_less,be_less_thanbe_greater_or_equal_to(self, value): equivalent to ">=". With aliasesbe_greater_or_equal,be_greater_than_or_equal_tobe_lesser_or_equal_to(self, value): equivalent to "<=". With aliasesbe_lesser_or_equal,be_less_or_equal,be_less_than_or_equal_to,be_lesser_than_or_equal_tobe_numeric(self): checks ifself.valueis a number or string covertible to a number. With aliasbe_a_numberContainment and Emptinesscontain(self, value): equivalent to "in". With aliaseshave,includebe_contained_in(self, value): equivalent to "in". Qith aliasesbe_in,be_included_inbe_empty(self): checks ifself.valueis iterable andFalseTruthinessbe_true(self): checks ifself.valueisTruebe_false(self): checks ifself.valueisFalsebe_truthy(self): checks ifself.valuebehavestruein if statement. With aliasesbe_truey,be_trueishbe_falsey(self): checks ifself.valuebehavesfalsein if statement. With aliasesbe_falsy,be_falsishTypingbe_of_type(self, value): checks ifself.valueis of specified type. With aliasesbe_type,have_typeinherit(self, value): checks ifself.valueinherits/is a specified type.be_subclass_of,have_parentFunction MatchersFunction matchers can be called as such:expect.function(string.replace).to_return('strength').when_called_with('ing','ength')Currently available matchers are:to_return(self, value=None, type_of_value=None)- checks if function returns a specified value, or type, or both.to_raise(self, exception_type)- checks if function raises a specified exception.In each case we have to specify arguments with which function is called in.when_called_withmethod. Method has aliaseswhen_called_with_args,when_called_with_argumentsFilesystem MatchersFilesystem matchers can be called as such:expect.folder('/some/folder').to.contain('subfolder')Currently available matchers are:contain(self, name, type: Union[File, Folder, None, str] = None)- checks if folder contains a specified file or folder. If type is specified, it will check if file is file or folder is folder.contain_file(self, name)- checks if folder contains a specified file.contain_folder(self, name)- checks if folder contains a specified folder.exist(self)- checks if folder exists.be_empty(self)- checks if folder is empty.They can be used with bothexpect.folder('/some/folder').toandexpect.folder('/some/folder').to_notto check both positive and negative expectations.