Skip to content

Instantly share code, notes, and snippets.

View hcosta's full-sized avatar

Hektor hcosta

View GitHub Profile
import unittest
from calculator import Calculator
class TestMyCalculator(unittest.TestCase):
def setUp(self):
self.calc = Calculator()
def test_initial_value(self):
self.assertEqual(0, self.calc.value)
class Calculator:
def __init__(self):
self.value = 0
import unittest
# Importamos la clase calculadora
from calculator import Calculator
class TestMyCalculator(unittest.TestCase):
def test_initial_value(self):
calc = Calculator()
self.assertEqual(0, calc.value)
class Calculator:
pass
# Cargamos el módulo unittest
import unittest
# Creamos una clase heredando de TestCase
class TestMyCalculator(unittest.TestCase):
# Creamos una prueba para probar un valor inicial
def test_initial_value(self):
calc = Calculator()
self.assertEqual(0, calc.value)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test plot</title>
</head>
<body>
<h2>Gráfico embebido por imagen</h2>
@hcosta
hcosta / views.py
Last active November 29, 2018 12:30
import io
import matplotlib.pyplot as plt
from django.http import HttpResponse
from django.shortcuts import render
from matplotlib.backends.backend_agg import FigureCanvasAgg
from random import sample
def home(request):
@hcosta
hcosta / test.py
Last active September 7, 2018 16:05
from PyQt5.QtWidgets import QApplication, QMainWindow
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.setWindowTitle("Hola mundo")
self.setFixedSize(400, 200)
if __name__ == "__main__":
app = QApplication([])
from PyQt5.QtWidgets import QGridLayout, QMainWindow, QWidget, QApplication, QLineEdit, QLabel
from PyQt5.QtGui import QIntValidator
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.setWindowTitle("Regla de 3")
self.setupUi()
def setupUi(self):
@hcosta
hcosta / manual.md
Last active August 18, 2022 17:31
Desplegar Django en doplet Ubuntu 16.04 de Digital Ocean

Actualizamos el repositorio como root (lo indico con $)

$ add-apt-repository universe
$ apt-get update
$ apt-get upgrade

Instalamos las dependencias y python, que por defecto viene en la versión 2.7

$ apt-get install python3 nginx supervisor # postgresql postgresql-contrib (si no se quiere sqlite)