def test_result_1(self): """ Function to test data """ self.assertEqual(function(self.dict_1, self.dict_2), { 'a': 300, 'b': 200, 'c': 300 }, "Should be {'a': 300, 'b': 200, 'c': 300}")
def test_function(self): with open('input.txt') as f: input = f.read().splitlines() with open('output.txt') as f: output = f.read().splitlines() for i, o in zip(input, output): self.assertEqual(str(function(i)), o)
def test_1(): assert function(3, 6) is False
def test(self): self.assertEqual(function(3), 4)
def test_regression_true(self): # точно истинный вариант s1 = '1234567' s2 = '456' self.assertEqual(function(s1, s2), s1.find(s2))
from flask import Flask,render_template,request,redirect,send_file,send_from_directory import os from werkzeug.utils import secure_filename from main import function app=Flask(__name__)#object of flask fn=function() fname="" @app.route('/',methods=['GET','POST']) #it is decorator def encryption(): app.config['UPLOAD_FOLDER'] = 'data/encrypteddata' #FILE UPLOADING METHOD if request.method == 'POST' and request.form["action"]=="up": print("yeah") print("Button press=",request.form['action']) # check if the post request has the file part if 'file' not in request.files: # flash('No file part') return redirect(request.url) file = request.files['file'] # if user does not select file, browser alsode # submit a empty part without filename if file.filename == '': # flash('No selected file') return redirect(request.url) if file : filenames = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filenames))
def test_s2_bigger(self): s1 = '123' s2 = '12345' self.assertEqual(function(s1, s2), s1.find(s2))
def test_regression_false(self): # точно ложный вариант s1 = '1234567' s2 = '46' self.assertEqual(function(s1, s2), s1.find(s2))
def test_nul_all(self): # компромиссный вариант s1 = '' s2 = '' self.assertEqual(function(s1, s2), s1.find(s2))
def test_max(self): s1 = '' for i in range(100000): s1 += str(randint(0, 9)) s2 = '1234567' self.assertEqual(function(s1, s2), s1.find(s2))
def test_null_s2(self): s1 = '123' s2 = '' self.assertEqual(function(s1, s2), s1.find(s2))
def test_null_s1(self): s1 = '' s2 = "123" self.assertEqual(function(s1, s2), s1.find(s2))
def test_random(self): for i in range(500): s1 = str(randint(0, 1000000)) s2 = str(randint(0, 1000000)) self.assertEqual(function(s1, s2), s1.find(s2))
def test_2(): assert function(10, 5) is True
def test_equal(self): s1 = '12345' self.assertEqual(function(s1, s1), s1.find(s1))
import main main.function()
def test_searching(self): with open('data.txt') as f: lines = f.readlines() self.assertEqual('4', function(lines[0])) self.assertEqual('', function(lines[1])) self.assertEqual('8,9', function(lines[2]))