function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def ctime(self): return self._ctime
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def ctime(self, value): self._ctime = self._validate_integer("ctime", value)
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def generation(self): return self._generation
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def generation(self, value): self._generation = self._validate_integer("generation", value)
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def sequence(self): return self._sequence
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def sequence(self, value): self._sequence = self._validate_integer("sequence", value)
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def _validate_integer(cls, property, value): if not isinstance(value, six.integer_types): raise AssertionError( "Invalid value for metadata property {!r}: {!r}".format( property, value)) return value
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def validate_description(cls, desc): desc = str(desc) # We cannot fail when the description is too long, since we must # support older engine that may send such values, or old disks # with long description. if len(desc) > sc.DESCRIPTION_SIZE: cls.log.warning("Descript...
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def __getitem__(self, item): try: value = getattr(self, self._fieldmap[item]) except AttributeError: raise KeyError(item) # Some fields needs to be converted to string if item in (sc.CAPACITY, sc.CTIME): value = str(value) return value
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def get(self, item, default=None): try: return self[item] except KeyError: return default
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def testProcessDeviceParams(self): deviceXML = hostdev._process_device_params( libvirtconnection.get().nodeDeviceLookupByName( hostdevlib.ADDITIONAL_DEVICE).XMLDesc() ) self.assertEqual( hostdevlib.ADDITIONAL_DEVICE_PROCESSED, deviceXML ...
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def testProcessDeviceParamsInvalidEncoding(self): deviceXML = hostdev._process_device_params( libvirtconnection.get().nodeDeviceLookupByName( hostdevlib.COMPUTER_DEVICE).XMLDesc() ) self.assertEqual( hostdevlib.COMPUTER_DEVICE_PROCESSED, devic...
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def testProcessSRIOV_VFDeviceParams(self): deviceXML = hostdev._process_device_params( libvirtconnection.get().nodeDeviceLookupByName( hostdevlib.SRIOV_VF).XMLDesc() ) self.assertEqual(hostdevlib.SRIOV_VF_PROCESSED, deviceXML)
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def testProcessMdevDeviceParams(self): deviceXML = hostdev._process_device_params( libvirtconnection.get().nodeDeviceLookupByName( hostdevlib.MDEV_DEVICE).XMLDesc() ) self.assertEqual(hostdevlib.MDEV_DEVICE_PROCESSED, deviceXML)
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def testListByCaps(self, caps): devices = hostdev.list_by_caps(caps) for cap in caps: self.assertTrue(set(hostdevlib.DEVICES_BY_CAPS[cap].keys()). issubset(set(devices.keys())))
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def test_device_name_from_address(self, addr_type, addr, name): # we need to make sure we scan all the devices (hence caps=None) hostdev.list_by_caps() self.assertEqual( hostdev.device_name_from_address(addr_type, addr), name )
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def test_3k_storage_devices(self): with hostdevlib.Connection.use_hostdev_tree(): self.assertEqual( len(hostdev.list_by_caps()), len(libvirtconnection.get().listAllDevices()) )
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def setUp(self): self.conf = { 'vmName': 'testVm', 'vmId': '9ffe28b6-6134-4b1e-8804-1185f49c436f', 'smp': '8', 'maxVCpus': '160', 'memSize': '1024', 'memGuaranteedSize': '512'}
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def testCreateSRIOVVF(self): dev_spec = {'type': hwclass.NIC, 'device': 'hostdev', 'hostdev': hostdevlib.SRIOV_VF, 'macAddr': 'ff:ff:ff:ff:ff:ff', 'specParams': {'vlanid': 3}, 'bootOrder': '9'} device = network.Interface(sel...
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def setUp(self): def make_device(name): mdev_types = [ hostdevlib.FakeMdevType('incompatible-1', 2), hostdevlib.FakeMdevType('8q', 1), hostdevlib.FakeMdevType('4q', 2), hostdevlib.FakeMdevType('incompatible-2', 2), ] ...
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def test_vgpu_placement(self, mdev_specs, mdev_placement, instances): with MonkeyPatchScope([ (hostdev, '_each_mdev_device', lambda: self.devices) ]): for mdev_type, mdev_uuid in mdev_specs: hostdev.spawn_mdev(mdev_type, mdev_uuid, mdev_placement, ...
oVirt/vdsm
[ 129, 183, 129, 68, 1351274855 ]
def borat(self, mess, args): """ Random quotes from the DEVOPS_BORAT twitter account """ myfeed = parse('http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=DEVOPS_BORAT') items = myfeed['entries'] return choice(items).description
errbotio/err-devops-borat
[ 6, 4, 6, 1, 1337606195 ]
def jesus(self, mess, args): """ Random quotes from the devops_jesus twitter account """ myfeed = parse('http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=devops_jesus') items = myfeed['entries'] return choice(items).description
errbotio/err-devops-borat
[ 6, 4, 6, 1, 1337606195 ]
def __init__ (self, plugin, address): self.plugin = plugin # Call constructor of the parent class asynchat.async_chat.__init__(self) # Set up input line terminator self.set_terminator('\r\n') # Initialize input data buffer self.buffer = '' # create and...
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def handle_expt(self): # connection failed self.plugin.isSessionRunning = False self.plugin.TriggerEvent("NoConnection") self.close()
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def collect_incoming_data(self, data): """ Called with data holding an arbitrary amount of received data. """ self.buffer = self.buffer + data
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def __call__(self): self.plugin.DoCommand(self.value)
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def __call__(self, Param): self.plugin.DoCommand(self.value + " " + Param)
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def __call__(self): self.plugin.DoCommand("5000 " + self.value)
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def __init__(self): self.host = "localhost" self.port = 2663 self.isSessionRunning = False self.timeline = "" self.waitStr = None self.waitFlag = threading.Event() self.PlayState = -1 self.lastMessage = {} self.lastSubtitleNum = 0 self.last...
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def ValueUpdate(self, text): if text == self.waitStr: self.waitStr = None self.waitFlag.set() return header = text[0:4] state = text[5:].decode('utf-8') self.lastMessage[header] = state ttEvent = self.ttEvents.get(header, None) if ttEve...
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def DoCommand(self, cmdstr): self.waitFlag.clear() self.waitStr = cmdstr if not self.isSessionRunning: self.session = TheaterTekSession(self, (self.host, self.port)) self.isSessionRunning = True try: self.session.sendall(cmdstr + "\r\n") except...
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def Configure( self, host="localhost", port=2663, dummy1=None, dummy2=None
EventGhost/EventGhost
[ 368, 86, 368, 69, 1390085124 ]
def load_font(font_path): """ Load a new TTF font into Blender, and return the font object """ # get the original list of fonts (before we add a new one) original_fonts = bpy.data.fonts.keys()
XXLRay/libreshot
[ 1, 1, 1, 4, 1442911504 ]
def __init__(self, db, subscription, ds, address, timestamp_range=None, port=None, page_size=50): self.db = db self.sub = subscription self.table_nodes = "s{acct}_Nodes".format(acct=self.sub) self.table_links = "s{acct}_ds{id}_Links".format(acct=self.sub, id=ds) self.table_links_...
riolet/SAM
[ 175, 17, 175, 5, 1467750068 ]
def build_where_clause(self, timestamp_range=None, port=None, protocol=None, rounding=True): """ Build a WHERE SQL clause that covers basic timerange, port, and protocol filtering. :param timestamp_range: start and end times as unix timestamps (integers). Default is all time. :type times...
riolet/SAM
[ 175, 17, 175, 5, 1467750068 ]
def get_details_ports(self, page=1, order="-links"): sort_options = ['links', 'port'] first_result = (page - 1) * self.page_size qvars = { 'links_table': self.table_links, 'start': self.ip_start, 'end': self.ip_end, 'first': first_result, ...
riolet/SAM
[ 175, 17, 175, 5, 1467750068 ]
def get_mutually_exclusive_required_option(options, *selections): """ Validates that exactly one of the 2 given options is specified. Returns the name of the found option. """ selected = [sel for sel in selections if options.get(sel)] if len(selected) != 1: selection_string = ', '.join(...
eduNEXT/edunext-platform
[ 28, 7, 28, 10, 1414072000 ]
def validate_dependent_option(options, dependent_option, depending_on_option): """ Validates that option_1 is specified if dependent_option is specified. """ if options.get(dependent_option) and not options.get(depending_on_option): raise CommandError(f'Option --{dependent_option} requires optio...
eduNEXT/edunext-platform
[ 28, 7, 28, 10, 1414072000 ]
def addTemplate(core): mobileTemplate = MobileTemplate()
ProjectSWGCore/NGECore2
[ 23, 70, 23, 56, 1372673790 ]
def __init__(self,dae,nk): self.dae = dae self.nk = nk self._gaussNewtonObjF = [] mapSize = len(self.dae.xNames())*(self.nk+1) + len(self.dae.pNames()) V = C.msym('dvs',mapSize) self._dvMap = nmheMaps.VectorizedReadOnlyNmheMap(self.dae,self.nk,V) self._boundMap...
ghorn/rawesome
[ 10, 9, 10, 17, 1348591411 ]
def lookup(self,name,timestep=None): try: return self._dvMap.lookup(name,timestep=timestep) except NameError: pass try: return self._outputMap.lookup(name,timestep) except NameError: pass raise NameError("unrecognized name \""+name+...
ghorn/rawesome
[ 10, 9, 10, 17, 1348591411 ]
def guess(self,name,val,timestep=None): self._guessMap.setVal(name,val,timestep=timestep)
ghorn/rawesome
[ 10, 9, 10, 17, 1348591411 ]
def setObj(self,obj): if hasattr(self,'_obj'): raise ValueError("don't change the objective function") self._obj = obj
ghorn/rawesome
[ 10, 9, 10, 17, 1348591411 ]
def _setupDynamicsConstraints(self,endTime,traj): # Todo: add parallelization # Todo: get endTime right g = [] nicp = 1 deg = 4 p = self._dvMap.pVec() for k in range(self.nk): newton = Newton(LagrangePoly,self.dae,1,nicp,deg,'RADAU') newton...
ghorn/rawesome
[ 10, 9, 10, 17, 1348591411 ]
def runSolver(self,U,trajTrue=None): # make sure all bounds are set (xMissing,pMissing) = self._guessMap.getMissing() msg = [] for name in xMissing: msg.append("you forgot to set a guess for \""+name+"\" at timesteps: "+str(xMissing[name])) for name in pMissing: ...
ghorn/rawesome
[ 10, 9, 10, 17, 1348591411 ]
def _load_lib(): """Load xlearn shared library""" lib_path = find_lib_path() if len(lib_path) == 0: return None lib = ctypes.cdll.LoadLibrary(lib_path[0]) return lib
PKU-Cloud-Lab/xLearn
[ 3039, 537, 3039, 195, 1497082171 ]
def _check_call(ret): """Check the return value of C API call This function will raise exception when error occurs. Wrap every API call with this function Parameters ---------- ret : int return value from API calls """ if ret != 0: msg = "" # raise XLearnError()...
PKU-Cloud-Lab/xLearn
[ 3039, 537, 3039, 195, 1497082171 ]
def c_str(string): """Create ctypes char * from a Python string. Parameters ---------- string : string type Pyrhon string. Returns ------- str : c_char_p A char pointer that can be passed to C API. Examples -------- ...
PKU-Cloud-Lab/xLearn
[ 3039, 537, 3039, 195, 1497082171 ]
def c_str(string): """Create ctypes char * from a Python string. Parameters ---------- string : string type Pyrhon string. Returns ------- str : c_char_p A char pointer that can be passed to C API. Examples -------- >...
PKU-Cloud-Lab/xLearn
[ 3039, 537, 3039, 195, 1497082171 ]
def test_successful_provider_removal(): """ Here we give the module a text file with PROVIDER: written in it, it should remove that line in the file """ remove_provider = remove.RemoveProviderR() remove.web = WebDummy() # override the web variable in remove.py test_provider = "PROV" expect...
CyberReboot/vcontrol
[ 5, 12, 5, 64, 1470093229 ]
def check_label_shapes(labels, preds, wrap=False, shape=False): """Helper function for checking shape of label and prediction Parameters ---------- labels : list of `NDArray` The labels of the data. preds : list of `NDArray` Predicted values. wrap : boolean If True, wr...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, name, output_names=None, label_names=None, **kwargs): self.name = str(name) self.output_names = output_names self.label_names = label_names self._kwargs = kwargs self.reset()
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def get_config(self): """Save configurations of metric. Can be recreated from configs with metric.create(**config) """ config = self._kwargs.copy() config.update({ 'metric': self.__class__.__name__, 'name': self.name, 'output_names': self.outpu...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def update(self, labels, preds): """Updates the internal evaluation result. Parameters ---------- labels : list of `NDArray` The labels of the data. preds : list of `NDArray` Predicted values. """ raise NotImplementedError()
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def get(self): """Gets the current evaluation result. Returns ------- names : list of str Name of the metrics. values : list of float Value of the evaluations. """ if self.num_inst == 0: return (self.name, float('nan')) e...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def create(metric, *args, **kwargs): """Creates evaluation metric from metric names or instances of EvalMetric or a custom metric function. Parameters ---------- metric : str or callable Specifies the metric to create. This argument must be one of the below: - Name of a met...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, metrics=None, name='composite', output_names=None, label_names=None): super(CompositeEvalMetric, self).__init__( 'composite', output_names=output_names, label_names=label_names) if metrics is None: metrics = [] self.metrics = [create(i)...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def get_metric(self, index): """Returns a child metric. Parameters ---------- index : int Index of child metric in the list of metrics. """ try: return self.metrics[index] except IndexError: return ValueError("Metric index {} i...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def update(self, labels, preds): """Updates the internal evaluation result. Parameters ---------- labels : list of `NDArray` The labels of the data. preds : list of `NDArray` Predicted values. """ for metric in self.metrics: m...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def get(self): """Returns the current evaluation result. Returns ------- names : list of str Name of the metrics. values : list of float Value of the evaluations. """ names = [] values = [] for metric in self.metrics: ...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, axis=1, name='accuracy', output_names=None, label_names=None): super(Accuracy, self).__init__( name, axis=axis, output_names=output_names, label_names=label_names) self.axis = axis
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, top_k=1, name='top_k_accuracy', output_names=None, label_names=None): super(TopKAccuracy, self).__init__( name, top_k=top_k, output_names=output_names, label_names=label_names) self.top_k = top_k assert(self.top_k > 1), 'Please use Accu...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self): self.true_positives = 0 self.false_negatives = 0 self.false_positives = 0 self.true_negatives = 0
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def precision(self): if self.true_positives + self.false_positives > 0: return float(self.true_positives) / (self.true_positives + self.false_positives) else: return 0.
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def recall(self): if self.true_positives + self.false_negatives > 0: return float(self.true_positives) / (self.true_positives + self.false_negatives) else: return 0.
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def fscore(self): if self.precision + self.recall > 0: return 2 * self.precision * self.recall / (self.precision + self.recall) else: return 0.
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def total_examples(self): return self.false_negatives + self.false_positives + \ self.true_negatives + self.true_positives
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, name='f1', output_names=None, label_names=None, average="macro"): self.average = average self.metrics = _BinaryClassificationMetrics() EvalMetric.__init__(self, name=name, output_names=output_names, label_names=label_names)
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def reset(self): """Resets the internal evaluation result to initial state.""" self.sum_metric = 0. self.num_inst = 0. self.metrics.reset_stats()
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, ignore_label, axis=-1, name='perplexity', output_names=None, label_names=None): super(Perplexity, self).__init__( name, ignore_label=ignore_label, output_names=output_names, label_names=label_names) self.ignore_label = ignore_label self...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def get(self): """Returns the current evaluation result. Returns ------- Tuple of (str, float) Representing name of the metric and evaluation result. """ return (self.name, math.exp(self.sum_metric/self.num_inst))
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, name='mae', output_names=None, label_names=None): super(MAE, self).__init__( name, output_names=output_names, label_names=label_names)
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, name='mse', output_names=None, label_names=None): super(MSE, self).__init__( name, output_names=output_names, label_names=label_names)
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, name='rmse', output_names=None, label_names=None): super(RMSE, self).__init__( name, output_names=output_names, label_names=label_names)
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, eps=1e-12, name='cross-entropy', output_names=None, label_names=None): super(CrossEntropy, self).__init__( name, eps=eps, output_names=output_names, label_names=label_names) self.eps = eps
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, eps=1e-12, name='nll-loss', output_names=None, label_names=None): super(NegativeLogLikelihood, self).__init__( name, eps=eps, output_names=output_names, label_names=label_names) self.eps = eps
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, name='pearsonr', output_names=None, label_names=None): super(PearsonCorrelation, self).__init__( name, output_names=output_names, label_names=label_names)
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, name='loss', output_names=None, label_names=None): super(Loss, self).__init__( name, output_names=output_names, label_names=label_names)
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, name='torch', output_names=None, label_names=None): super(Torch, self).__init__( name, output_names=output_names, label_names=label_names)
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, name='caffe', output_names=None, label_names=None): super(Caffe, self).__init__( name, output_names=output_names, label_names=label_names)
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def __init__(self, feval, name=None, allow_extra_outputs=False, output_names=None, label_names=None): if name is None: name = feval.__name__ if name.find('<') != -1: name = 'custom(%s)' % name super(CustomMetric, self).__init__( name, ...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def get_config(self): raise NotImplementedError("CustomMetric cannot be serialized")
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def np(numpy_feval, name=None, allow_extra_outputs=False): """Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy a...
TuSimple/mxnet
[ 28, 25, 28, 1, 1457693796 ]
def Args(parser): """Register flags for this command.""" parser.add_argument( 'name', help='Name of the function to be called.', type=util.ValidateFunctionNameOrRaise) parser.add_argument( '--data', default='', help='Data passed to the function (JSON string)')
KaranToor/MA450
[ 1, 1, 1, 4, 1484697944 ]
def test_can_write_simple_identifier(self): escaped = cypher_escape("foo") assert escaped == "foo"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_can_write_identifier_containing_back_ticks(self): escaped = cypher_escape("foo `bar`") assert escaped == "`foo ``bar```"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_cannot_write_none_identifier(self): with self.assertRaises(TypeError): _ = cypher_escape(None)
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_none(self): encoded = cypher_repr(None) assert encoded == u"null"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_true(self): encoded = cypher_repr(True) assert encoded == u"true"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_zero(self): encoded = cypher_repr(0) assert encoded == u"0"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_negative_integer(self): encoded = cypher_repr(-123) assert encoded == u"-123"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_zero(self): encoded = cypher_repr(0.0) assert encoded == u"0.0"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_negative_float(self): encoded = cypher_repr(-123.456) assert encoded == u"-123.456"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_bytes(self): encoded = cypher_repr(b"hello, world") assert encoded == u"'hello, world'"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_bytes_with_escaped_chars(self): encoded = cypher_repr(b"hello, 'world'", quote=u"'") assert encoded == u"'hello, \\'world\\''"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_empty_string(self): encoded = cypher_repr(u"") assert encoded == u"''"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_backspace(self): encoded = cypher_repr(u"\b") assert encoded == u"'\\b'"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_new_line(self): encoded = cypher_repr(u"\n") assert encoded == u"'\\n'"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]
def test_should_encode_horizontal_tab(self): encoded = cypher_repr(u"\t") assert encoded == u"'\\t'"
technige/cypy
[ 5, 2, 5, 1, 1445556635 ]