This file contains hidden or 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
<?php | |
$global = array(); | |
$reference = &$global; | |
$copy = $global; | |
$global[] = "global"; | |
$reference[] = "reference"; | |
$copy[] = "copy"; |
This file contains hidden or 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
project/ # project root | |
conf/ # config files, could also be put in project/project/ | |
lib/ # some libraries, probably you don't need it if you use a package manager like pip. | |
project/ | |
__init__.py | |
project.py | |
core.py | |
submodule/ | |
__init__.py | |
submodule.py |
This file contains hidden or 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
# entity.py | |
def delete_entity(some_entity_id): | |
session.query(Entity).filter(Entity.id == some_entity_id).delete() | |
session.commit() | |
# test_entity.py | |
def test_delete_entity(): | |
# Assume DB contains 1 entity with ID 1. | |
assert len(session.query(Entity).all()) == 1 # Passes always | |
This file contains hidden or 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
#project.py | |
if __name__ == '__main__': | |
from project.model import Base, Log | |
from project.db import engine | |
Base.metadata.create_all(engine) # Log shows me that table has been created. | |
# models.py | |
# .. imports and stuf |
This file contains hidden or 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
#conftest.py | |
from project import Session | |
from project.model import Model | |
import pytest | |
@pytest.fixture | |
def model(): | |
model = Model(value='some_value') | |
Session.add(model) |
This file contains hidden or 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
version: 1 | |
formatters: | |
simple: | |
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s" | |
handlers: | |
console: | |
class: logging.StreamHandler | |
formatter: simple | |
level: DEBUG | |
stream: ext://sys.stdout |
This file contains hidden or 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
setpoints = [a, b, c, d, e] # List with setpoints, ordered by time. | |
sum_values = 0 | |
sum_seconds = 0 | |
for index, current_setpoint in enumerate(setpoints): | |
try: | |
next_setpoint = setpoints[index+1] | |
except KeyError: | |
return | |
This file contains hidden or 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
# event.py | |
class Event(): | |
# some implentation of adding, deleting and firing event handlers | |
pass | |
class ErrorEvent(Event): | |
pass | |
# some_file.py | |
from event import ErrorEvent |
This file contains hidden or 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
#conftest.py | |
import pytest | |
@pytest.fixture | |
def db(): | |
test_db.create_all() | |
return test_db | |
This file contains hidden or 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
# my_app.py | |
from math import power | |
def some_fun(i): | |
if power(i) > 10: | |
return True | |
return False | |
# test_my_app.py |