This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<script> | |
// ......................................................................... // | |
/* | |
* Function to wrap every method in the function to have self | |
*/ | |
function selfify (obj) { | |
// go over each property in the given object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
""" | |
from importlib import import_module | |
from inspect import stack | |
from inspect import ismethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Sample Test Cases More Injections | |
""" | |
from unittest import TestCase | |
# --------------------------------------------------------------------------- # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import makedirs | |
from unittest import TestCase | |
def foo(_default_folder='foo', _os_makedirs=makedirs): | |
""" | |
The purpose of this function is to create a folder called 'foo' | |
on the file system. | |
""" | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------------------------- # | |
class Foo(object): | |
# ....................................................................... # | |
def get_string(self): | |
return "hello" | |
# ....................................................................... # | |
def reverse_string(self, str_=self.get_string()): | |
return str_[::-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(object): | |
def bar(value): | |
if value == 11: | |
raise ValueError() | |
return value | |
def hello(msg): | |
return msg | |
class TestFoo_bar(TestCase): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(object): | |
_prop1 = None | |
_prop2 = None | |
_prop3 = None | |
def set_prop1(self, value): | |
self._prop1 = self._set_if_valid(value) | |
def set_prop2(self, value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FooError(Exception): pass | |
def public_api1(x): | |
""" | |
Return given value, after making sure it is not 1. | |
:param x: value: | |
:type x: int | |
:raises: ForError if x == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File Edit Options Buffers Tools Python Help | |
class Bar(object): | |
def meth1(self): | |
pass | |
class Foo(Bar): | |
def meth2(self, func=Bar.meth1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JsonSerializableMixin(object): | |
""" | |
Converts all the properties of the object into a dict for use in json. | |
You can define the following as your class properties. | |
_json_eager_load : | |
list of which child classes need to be eagerly loaded. This applies | |
to one-to-many relationships defined in SQLAlchemy classes. | |
_base_blacklist : |