Pytest share fixture data across the class methods

2019-06-26 Thread Arup Rakshit
are the data across all the methods instead of creating them everytime in each method as I did above. Can you suggest me some tricks? I am looking for something like: @pytest.mark.usefixtures("client_class") class TestUnauthorizedRecipesAcces: # def test_remove_a_category_from_a_recipe(self): assert ( self.client.delete( url_for( "recipe_categories.recipe_categories_api", _method="DELETE", recipe_id=self.recipe.id, id=self.category.id, ) ).status_code == 401 ) How can I achieve this. Fixtures create_recipe_record, create_category_record are created in contest.py file as a function scope (https://gitlab.com/aruprakshit/flask_awesome_recipes/blob/master/tests/conftest.py) . The tests can be seen here https://gitlab.com/aruprakshit/flask_awesome_recipes/blob/master/tests/test_recipes.py#L253 . Please give me some directions. Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Python refactoring question and create dynamic attributes

2019-06-23 Thread Arup Rakshit
> On 23-Jun-2019, at 2:31 PM, Cameron Simpson wrote: > > On 23Jun2019 13:26, Arup Rakshit wrote: >> In the below code: >> >> @classmethod >> def find(self, id): >> if isinstance(id, list): >> rows = self.__table__().get_all(*id

Python refactoring question and create dynamic attributes

2019-06-23 Thread Arup Rakshit
/flask_awesome_recipes/blob/master/app/models/category.py Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Help a noob out

2019-05-02 Thread Arup Rakshit
born? 1989 30 Thanks, Arup Rakshit a...@zeit.io > On 02-May-2019, at 2:50 PM, felixen...@hotmail.co.uk wrote: > > birth_year = input("What year are you born? ") > current_year = 2019 > age = current_year - birth_year > print(age) -- https://mail.python.org/mailman/listinfo/python-list

Python Flask-CouchDB - AttributeError: '_AppCtxGlobals' object has no attribute 'couch'

2019-05-01 Thread Arup Rakshit
in full_dispatch_request rv = self.dispatch_request() File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/aruprakshit/projects/flask-apps/todo-app/app.py", line 14, in index g.couch['users'] = document File "/Users/aruprakshit/projects/flask-apps/todo-app/venv/lib/python3.7/site-packages/werkzeug/local.py", line 348, in __getattr__ return getattr(self._get_current_object(), name) AttributeError: '_AppCtxGlobals' object has no attribute ‘couch' Can anyone help me to fix this? Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Why not being able to call modules from lib folder into test folder although I have __init__.py file both?

2019-04-26 Thread Arup Rakshit
On 26/04/19 11:14 AM, dieter wrote: Arup Rakshit writes: I am not able to call modules from lib folder in my test folder, but outside of tests folder I can access them. How should I fix this? Mocks$ tree . . ├── lib │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc

How to convert a train running program from synchronous to asynchronous?

2019-04-26 Thread Arup Rakshit
et the control back, and keep querying what the next stoppage is. something like this: train.run() while len(train.stations) is not 0: print(f"Next stoppage is {train.stations[0]}") How should I modify this current program to meet my goal? Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Why not being able to call modules from lib folder into test folder although I have __init__.py file both?

2019-04-25 Thread Arup Rakshit
mething = mock.MagicMock() def test_method(self): self.real.method() self.real.something.assert_called_once_with(1, 2, 3) if __file__ == "__main__": unittest.main() Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Questions on Instance methods

2019-04-21 Thread Arup Rakshit
tutorial does. I am reading https://docs.python.org/3/reference/index.html now, and it seems like saying what Python can do, but not going deep to explain it to a new comers most of the time. Thanks, Arup Rakshit a...@zeit.io > On 20-Apr-2019, at 10:59 AM, dieter wrote: > > Aru

Questions on Instance methods

2019-04-19 Thread Arup Rakshit
quivalent to calling f(C,1)” ? Quotes are taken from https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy under Callable types -> User-defined functions / Instance methods Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Question regarding the __kwdefaults__ output being None

2019-04-19 Thread Arup Rakshit
Hi Peter, Thanks for explaining it. Beautiful. Thanks, Arup Rakshit a...@zeit.io > On 19-Apr-2019, at 5:53 PM, Peter Otten <__pete...@web.de> wrote: > > Arup Rakshit wrote: > >> I have a very basic function. >> >> def greet(name, msg = "Goo

Question regarding the __kwdefaults__ output being None

2019-04-19 Thread Arup Rakshit
rmation. from python_methods import greet greet("Kate") Hello Kate, Good morning! greet("Bruce","How do you do?") Hello Bruce, How do you do? print(greet.__kwdefaults__) None What am I missing here? Should not I get {“msg”: “Good morning!”} ? Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: immutability is not strictly the same as having an unchangeable value, it is more subtle

2019-04-17 Thread Arup Rakshit
Hi All, Thanks for explaining it so nice way. I got it now. What protocols I need to learn, to define a custom immutable class ? Thanks, Arup Rakshit a...@zeit.io > On 16-Apr-2019, at 10:54 PM, Dennis Lee Bieber wrote: > > On Tue, 16 Apr 2019 13:13:18 +0530, Arup Rakshit decl

immutability is not strictly the same as having an unchangeable value, it is more subtle

2019-04-16 Thread Arup Rakshit
t the author meant will be helpful. Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Python list and Python Journeymen*

2019-04-13 Thread Arup Rakshit
? Thanks, Arup Rakshit a...@zeit.io > On 14-Apr-2019, at 5:28 AM, DL Neil wrote: > > * and Journey(wo)men > > TL;DR? Please scroll the bottom with a view to contributing advice > > > Hello Arup, > > I appreciate your confidence and trust in writing to me personally.

Re: Why inspect.isclass says iter() a class?

2019-04-10 Thread Arup Rakshit
Well. I thought so far, all class in python is defined as CamelCase. A function can be a class to is something I am surprised. So does this mean, any callable function if produce an instance is called class in Python? Thanks, Arup Rakshit a...@zeit.io > On 11-Apr-2019, at 12:53

Why inspect.isclass says iter() a class?

2019-04-10 Thread Arup Rakshit
>From docs https://docs.python.org/3/library/itertools.html#itertools.chain I >see that itertools.chain is defined as a function. But then why >inspect.isclass(chain) is saying it as class. from itertools import chain inspect.isclass(chain) # True Thanks, Arup Rakshit a..

Re: I want understand how this word wrap program playing on input

2019-04-06 Thread Arup Rakshit
us. :) The whole series will cost me INR 2768.55. Thanks, Arup Rakshit a...@zeit.io > On 07-Apr-2019, at 2:02 AM, DL Neil wrote: > > Arup, > > Good choice! (thought I recognised the example-problem) The three books in > the "Python Craftsman" series/bundle: &qu

Re: I want understand how this word wrap program playing on input

2019-04-06 Thread Arup Rakshit
. In that case, I am 100% sure the analogies were used in this email would never come to me. Thanks again to all of you. Thanks, Arup Rakshit a...@zeit.io > On 05-Apr-2019, at 1:24 AM, DL Neil wrote: > > Arup, > > On 5/04/19 7:33 AM, Arup Rakshit wrote: >> I am

I want understand how this word wrap program playing on input

2019-04-04 Thread Arup Rakshit
use why `current_line_length` is set back to 0 every time the condition is true. 3. Also why that `if` test is required there. Can anyone help me to understand this program, I am totally confused. Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Why do I need to use pip3 but not pip

2019-03-30 Thread Arup Rakshit
Hi Peter, This is awesome. Now where should I put my source code? I see many folders into it. Thanks, Arup Rakshit a...@zeit.io > On 30-Mar-2019, at 3:26 PM, Peter Otten <__pete...@web.de> wrote: > > Arup Rakshit wrote: > >> Hello All, >> >> Tha

Re: Why do I need to use pip3 but not pip

2019-03-30 Thread Arup Rakshit
Hello All, Thanks I got it now. One related question: Can I use pip3 for example to install packages project specific, but not globally? So that when I delete the project, all of them gone also from my disk. Thanks, Arup Rakshit a...@zeit.io > On 30-Mar-2019, at 2:05 PM, Cameron Simp

Why do I need to use pip3 but not pip

2019-03-30 Thread Arup Rakshit
--version pip 18.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7) Do I always need to install using pip3 program then? Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Understanding the MRO with multiple inheritance

2019-03-30 Thread Arup Rakshit
at(IntList.__mro__)) # MRO of SortedIntList (, , , , ) # MRO of IntList (, , ) I thought obj.add(0) goes to the IntList by following its factory class __mro__, and then it follows the __mro__ of the current class(IntList) which is SimpleList . Thanks again. Thanks, Arup Rakshit a...@zeit.io >

Re: Understanding the MRO with multiple inheritance

2019-03-29 Thread Arup Rakshit
Hello DL, I am using Python3. Thanks, Arup Rakshit a...@zeit.io > On 30-Mar-2019, at 6:58 AM, DL Neil wrote: > > Arup, > > There is a minefield here. Are you using Python 2 or 3? > > -- > Regards =dn > -- > https://mail.python.org/mailman/l

Understanding the MRO with multiple inheritance

2019-03-29 Thread Arup Rakshit
se class SimpleList. But in reality it doesn’t, it rather forwards it to the SortedList add method. How MRO guides here can anyone explain please? I am little lost in the chain. ob = SortedIntList((2,4,3)) ob.add(0) print(ob) # SortedIntList([0, 2, 3, 4]) Thanks, Arup Rakshit a...@zeit.io -

Re: Why can't access the property setter using the super?

2019-03-19 Thread Arup Rakshit
Hello Ian, That seems like too much code involved. Is this how we do write inheritance in Python. Coming from Ruby and JS world I find Python inheritance mechanism confusing so far. :/ Thanks, Arup Rakshit a...@zeit.io > On 19-Mar-2019, at 9:32 PM, Ian Kelly wrote: > > Here&#x

Why can't access the property setter using the super?

2019-03-19 Thread Arup Rakshit
at it has no celsius setter, although it has. While this code doesn’t work how can I solve this. The thing I am trying here not to duplicate the validation of temperature which is already in the setter property of the RefrigeratedShippingContainer class. Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Reasoning of calling a method on class object instead of class instance object

2019-03-18 Thread Arup Rakshit
t(self, value): self.celsius = RefrigeratedShippingContainer._f_to_c(value) If I call `_c_to_f`, `_f_to_c` methods on `self` instead of `RefrigeratedShippingContainer` class object, still it works. So what is the reason behind of this calling on the class object, instead class instance

Re: I wrote a free book about TDD and clean architecture in Python

2019-03-18 Thread Arup Rakshit
Hello, Thanks for writing this great book. I joined python community just couple of weeks. Thanks, Arup Rakshit a...@zeit.io > On 16-Mar-2019, at 4:59 PM, giordani.leona...@gmail.com wrote: > > Hi all, > > I published on Leanpub a free book, "Clean Architecture

Question about the @staticmethod decorator

2019-03-17 Thread Arup Rakshit
function as static method of a class. Can anyone give me an example of this? What are the contexts that would let you to think if they are good fit inside the class or module level scope functions? Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Question regarding the local function object

2019-03-15 Thread Arup Rakshit
Nice explanation. Thank you very much. Thanks, Arup Rakshit a...@zeit.io > On 15-Mar-2019, at 6:24 PM, Calvin Spealman wrote: > > This is actually part of a not entirely uncommon misconception that can arise > by comparing objects only by their > repr() outp

Question regarding the local function object

2019-03-15 Thread Arup Rakshit
ter at 0x1051e0730> ['abc', 'def', 'ghi'] >>> sort_by_last_letter(['ghi', 'def', 'abc']) .last_letter at 0x1051e0730> ['abc', 'def', 'ghi'] >>> sort_by_last_letter(['ghi', 'def', 'abckl']) .last_letter at 0x1051e0730> ['def', 'ghi', 'abckl'] >>> Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Re: Python scope question

2019-03-12 Thread Arup Rakshit
Hello, Thanks for this beautiful link. This is amazing. Thanks, Arup Rakshit a...@zeit.io > On 13-Mar-2019, at 12:11 AM, DL Neil wrote: > > Arup, > > > On 13/03/19 3:38 AM, Arup Rakshit wrote: >> I have questions how nonlocal and global affecting the variable

Python scope question

2019-03-12 Thread Arup Rakshit
ter nonlocal assignment: nonlocal spam After global assignment: nonlocal spam In global scope: global spam Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list

Python resources recommendations

2019-03-09 Thread Arup Rakshit
/3/tutorial/index.html <https://docs.python.org/3/tutorial/index.html> . What next you would recommend me after this? I would like to learn Flask once I feel good with Python core. Thanks, Arup Rakshit a...@zeit.io -- https://mail.python.org/mailman/listinfo/python-list